home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / Reference / DevCon / Orlando_1993 / Devcon93.4 / Networking2 / AS225 / docs / socket.doc < prev   
Encoding:
Text File  |  1993-01-11  |  75.9 KB  |  3,060 lines

  1. TABLE OF CONTENTS
  2.  
  3. background
  4. socket.library/accept
  5. socket.library/bind
  6. socket.library/byteorder
  7. socket.library/cleanup_sockets
  8. socket.library/connect
  9. socket.library/endhostent
  10. socket.library/endnetent
  11. socket.library/endprotoent
  12. socket.library/endpwent
  13. socket.library/endservent
  14. socket.library/FD_SET
  15. socket.library/get_tz
  16. socket.library/getdomainname
  17. socket.library/getgid
  18. socket.library/getgroups
  19. socket.library/gethostbyaddr
  20. socket.library/gethostbyname
  21. socket.library/gethostent
  22. socket.library/gethostname
  23. socket.library/getlogin
  24. socket.library/getnetbyaddr
  25. socket.library/getnetbyname
  26. socket.library/getnetent
  27. socket.library/getpeername
  28. socket.library/getprotobyname
  29. socket.library/getprotobynumber
  30. socket.library/getprotoent
  31. socket.library/getpwent
  32. socket.library/getpwnam
  33. socket.library/getpwuid
  34. socket.library/getservbyname
  35. socket.library/getservbyport
  36. socket.library/getservent
  37. socket.library/getsockname
  38. socket.library/getsockopt
  39. socket.library/getuid
  40. socket.library/getumask
  41. socket.library/inet_addr
  42. socket.library/inet_lnaof
  43. socket.library/inet_makeaddr
  44. socket.library/inet_netof
  45. socket.library/inet_network
  46. socket.library/inet_ntoa
  47. socket.library/listen
  48. socket.library/rcmd
  49. socket.library/reconfig
  50. socket.library/recv
  51. socket.library/s_close
  52. socket.library/s_dev_list
  53. socket.library/s_getsignal
  54. socket.library/s_inherit
  55. socket.library/s_ioctl
  56. socket.library/s_release
  57. socket.library/s_syslog
  58. socket.library/select
  59. socket.library/selectwait
  60. socket.library/send
  61. socket.library/sethostent
  62. socket.library/setnetent
  63. socket.library/setprotoent
  64. socket.library/setpwent
  65. socket.library/setservent
  66. socket.library/setsockopt
  67. socket.library/setup_sockets
  68. socket.library/shutdown
  69. socket.library/socket
  70. socket.library/strerror
  71. socket.library/umask
  72. background                                                         background
  73.  
  74.     What is a socket library?
  75.  
  76.  The standard programmer's interface to network protocols on most
  77.  Un*x machines is the Berkley socket abstraction.  It is usually
  78.  provided as a link library. You should have as documentation the
  79.  books "Unix Network Programming" by W. Richard Stephens
  80.  (Prentice-Hall, 1990) and "Internetworking with TCP/IP, Volume II"
  81.  by Douglas Comer and David Stephens (Prentice-Hall, 1991).  We
  82.  don't get a kick-back from Prentice-Hall, but we do use these books
  83.  every day and we do know that writing programs using TCP/IP and
  84.  sockets can be difficult.
  85.  
  86.     Why a shared socket library?
  87.  
  88.  A shared library provides many benefits.  First, it greatly reduces
  89.  code size.  Second, it is compiler-independent.  However, the most
  90.  important benefit is that it is easily upgradable.  New libraries
  91.  with bug fixes, speed improvements, or additional functions can be
  92.  utilized by existing code without recompilation.  In the case of
  93.  the socket library, this means we can later add support for name
  94.  resolution, better configuration, DES, etc.
  95.  
  96.     Who should use this?
  97.  
  98.  Everyone.  The link socket library that received very limited alpha
  99.  distribution is obsolete.  Our primary goal in writing this socket
  100.  library is compatibility. BSD, SVR4, X/Open, POSIX and OSF sources
  101.  have been consulted when necessary.  All standard Unix socket
  102.  functions, with all their peculiarities have been faithfully ported
  103.  :^)  Unfortunately, due to the fact that these functions were not
  104.  designed with shared libraries or the Amiga in mind, some
  105.  compromises were made. 
  106.  
  107.     How to use this? 
  108.  
  109.  See "What is a socket library?" above.  To port existing socket code 
  110.  (from Un*x or from our obsolete link library), you must:
  111.  
  112.     OpenLibrary the socket.library and call setup_sockets()
  113.     not call read() or write() on sockets (use send() and recv())
  114.     call s_close() rather than close() for sockets
  115.     call s_ioctl() rather than ioctl() for sockets
  116.  
  117.  In case you're wondering, our old link library was
  118.  compiler-specific and included the compiler's library code for
  119.  read(), write(), close() and ioctl(). On Un*x machines, these
  120.  functions are just calls to the kernel which can deal with sockets
  121.  and other files.  Obviously, this is not possible with a shared
  122.  library on a machine where these functions come from link
  123.  libraries, hence the s_*() functions.
  124.  
  125.     About errno:
  126.  
  127.  'C' programmers should be familiar with the global variable
  128.  'errno.'  It is used extensively in standard socket implementations
  129.  to provide details about error conditions.  We take care of this in
  130.  the shared library by passing a pointer to 'errno' into the shared
  131.  library with setup_sockets().  You can, of course, pass a pointer
  132.  to any longword-aligned, four-byte chunk of memory you own, so this
  133.  will work for non-'C'-language programmers.
  134.  
  135.     About integers:
  136.  
  137.  All integers are assumed to be 32-bit.  None are specified as long
  138.  in order to maintain Un*x compatibility.  If you are using a
  139.  compiler which doesn't use 32-bit ints, you must make sure that all
  140.  ints are converted to longs by your code.
  141.  
  142.     About assembly langauge:
  143.  
  144.  To be complete, we probably should include assembly header files.
  145.  We don't.
  146.  
  147.     About the get*() functions:
  148.  
  149.  This is standard with the Un*x functions, too, but is worth noting:
  150.  These function return a pointer to a static buffer.  The buffer returned
  151.  by a call to getX*() is cleared on the next invocation of getX*().  For
  152.  example, the buffer pointed to by the return of gethostent() is cleared
  153.  by a call to gethostent(), gethostbyaddr() or gethostbyname(), but not
  154.  by a call to getprotoent(), etc.
  155.  
  156.  As noted in the autodocs, none of the get*ent(), set*ent() or end*ent()
  157.  functions should normally be used except for in porting existing programs
  158.  (and internally).
  159.  
  160.     About library bases:
  161.  
  162.  The shared socket library returns a different library base for each
  163.  OpenLib() and uses these different library bases to keep track of some
  164.  global data for each opener.  If you start a new process with a new
  165.  context, the new process must open and initialize socket.library.  Mere
  166.  tasks should not access the socket.library, only processes should.
  167.  
  168.     Example:
  169.  
  170.  /* your includes */
  171.  #include <exec/types.h>
  172.  #include <exec/libraries.h>
  173.  #include <exec/execbase.h>
  174.  #include <dos/dos.h>
  175.  #include <proto/all.h>
  176.  #include <sys/types.h>
  177.  #include <sys/socket.h>
  178.  #include <stdio.h>
  179.  #include <errno.h>
  180.  
  181.  /* the next two lines must always be here */
  182.  #include <ss/socket.h>
  183.  struct Library *SockBase ;
  184.  
  185.  /* this is the maximum number of sockets that you want */
  186.  #define MAXSOCKS 10
  187.  
  188.  main()
  189.  {
  190.     if((SockBase = OpenLibrary( "inet:libs/socket.library", 1L )) == NULL) {
  191.         printf("Error opening socket.library\n");
  192.         Exit(10);
  193.     }
  194.     setup_sockets( MAXSOCKS, &errno );
  195.  
  196.     /* normal socket code... (see AS225 dev disk for complete examples) */
  197.  
  198.     cleanup_sockets();
  199.     CloseLibrary( SockBase ) ;
  200.  }
  201.  
  202.     Legalese:
  203.  
  204.  This shared socket library (and it's documentation) are Copyright © 1991
  205.  Commodore-Amiga, Inc.  All Rights Reserved.  The shared socket library
  206.  was written by Martin Hunt.  Dale Larson helped with the documentation and
  207.  testing.
  208.  
  209.  Parts of this shared socket library and the associated header files are
  210.  derived from code which is:
  211.  
  212.  Copyright (c) 1983 Regents of the University of California.
  213.  All rights reserved.
  214.  
  215.  Redistribution and use in source and binary forms are permitted
  216.  provided that the above copyright notice and this paragraph are
  217.  duplicated in all such forms and that any documentation,
  218.  advertising materials, and other materials related to such
  219.  distribution and use acknowledge that the software was developed
  220.  by the University of California, Berkeley.  The name of the
  221.  University may not be used to endorse or promote products derived
  222.  from this software without specific prior written permission.
  223.  THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  224.  IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  225.  WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  226.  
  227. socket.library/accept                                   socket.library/accept
  228.  
  229.    NAME
  230.     accept -- Accept new connection from socket.
  231.  
  232.    SYNOPSIS
  233.     ns = accept( s, name, len )
  234.     D0           D0 A0    A1
  235.  
  236.     int accept(int, struct sockaddr *, int *);
  237.  
  238.    FUNCTION
  239.     Servers using TCP (or another connection-oriented protocol) accept()
  240.     connections initiated by a client program.  The connections are
  241.     generally accept()ed on a socket which on which bind() and listen()
  242.     have been executed.  Unless there is an error, accept() will return
  243.     a new socket which is connected to the client.  The server can then
  244.     use the new socket ('ns') to communicate with the client (via send()
  245.     and recv()) and still accept() new connections on the old socket
  246.     ('s').
  247.  
  248.     'Len' should be initialized to the amount of space pointed
  249.     to by 'name.'  The actual size of 'name' will be returned in
  250.     'namelen' and 'name' will contain the name of the socket initiating
  251.     the connect().  This saves the server from needing to do a
  252.     getpeername() for new connections.
  253.  
  254.     Accept() generally blocks until a client attempts a connect().
  255.     You may use select() to determine whether a connection is pending,
  256.     or use a non-blocking socket (see setsockopts()).
  257.  
  258.    INPUTS
  259.     s        - socket descriptor.
  260.     name        - name of the peer socket.
  261.     len        - pointer to the length of the sockaddr struct.
  262.               The value returned will be the actual size of the
  263.               sockaddr struct that was returned.
  264.  
  265.    RESULT
  266.     ns        - new socket descriptor or -1 (errno will be set to
  267.               reflect exact error condition).
  268.  
  269.    EXAMPLE
  270.  
  271.    NOTES
  272.  
  273.    BUGS
  274.  
  275.    SEE ALSO
  276.     socket(), bind(), listen()
  277.  
  278. socket.library/bind                                       socket.library/bind
  279.  
  280.    NAME
  281.     bind -- Bind a name to a socket.
  282.  
  283.    SYNOPSIS
  284.     return = bind( s, name, namelen )
  285.     D0             D0 A1    D1
  286.  
  287.     int bind(int, struct sockaddr *, int);
  288.  
  289.    FUNCTION
  290.     Assigns a name to an unnamed socket.
  291.  
  292.     Connection-oriented servers generally bind() a socket to a well-
  293.     known address and listen() at that socket, accept()ing connections
  294.     from clients who know the address.
  295.  
  296.     Connectionless servers generally bind() a socket to a well-known
  297.     address and recvfrom() that socket.
  298.  
  299.     Most servers should build 'name' from a well-known port obtained
  300.     from getservbyname().  Hard-coded ports are often used in prototype
  301.     servers, but should never be used in production code.  For more
  302.     information on port numbering, see your favorite TCP/IP refrence.
  303.  
  304.    INPUTS
  305.     s        - socket descriptor.
  306.     name        - address to bind to socket 's.'
  307.     namelen        - length (in bytes) of 'name.'
  308.  
  309.    RESULT
  310.     return        - 0 if successful else -1 (errno will contain the
  311.               specific error).
  312.  
  313.    EXAMPLE
  314.  
  315.    NOTES
  316.  
  317.    BUGS
  318.  
  319.    SEE ALSO
  320.     socket(), listen(), accept()
  321.  
  322. socket.library/byteorder                             socket.library/byteorder
  323.  
  324.    NAME
  325.     byteorder -- Macros to convert between host and network byte order.
  326.  
  327.    SYNOPSIS
  328.     #include <sys/types.h>
  329.     #include <netinet/in.h>
  330.  
  331.     netlong   = htonl ( hostlong );
  332.     netshort  = htons ( hostshort);
  333.     hostlong  = ntohl ( netlong );
  334.     hostshort = ntohs ( netshort);
  335.  
  336.    FUNCTION
  337.     These routines convert between host byte order to network byte
  338.     order.  This is necessary because not all CPUs store words and
  339.     longs in the same manner.  Some CPUs, called "Big Endian," store
  340.     words as high byte followed by low byte.  Others, called "Little
  341.     Endian," store a word as low byte followed by high byte.
  342.  
  343.     Big endian machines include IBM mainframes and Motorola 68000
  344.     family machines.  Little endian machines include DEC VAXen and
  345.     Intel 80x86 family CPUs.
  346.  
  347.     Network order is big endian.  Therefore, on big endian machines,
  348.     these functions are null macros.
  349.  
  350.    EXAMPLE
  351.  
  352.    NOTES
  353.     These macros are provided for portability.
  354.     They are null macros on the Amiga.
  355.  
  356.     #define htons(x)    (x)
  357.     #define ntohs(x)    (x)
  358.     #define htonl(x)    (x)
  359.     #define ntohl(x)    (x)
  360.  
  361.    SEE ALSO
  362.  
  363. socket.library/cleanup_sockets                 socket.library/cleanup_sockets
  364.  
  365.    NAME
  366.     cleanup_sockets -- Free global data for sockets.
  367.  
  368.    SYNOPSIS
  369.     cleanup_sockets( );
  370.  
  371.     void cleanup_sockets( void );
  372.  
  373.    FUNCTION
  374.     This function frees all signals and allocated memory.
  375.     It closes all open sockets.  This function should be
  376.     called after all socket functions are completed and before
  377.     CloseLibrary().
  378.  
  379.    INPUTS
  380.     None.
  381.  
  382.    RESULT
  383.     None.
  384.  
  385.    BUGS
  386.  
  387.    SEE ALSO
  388.     setup_sockets()
  389.  
  390. socket.library/connect                                 socket.library/connect
  391.  
  392.    NAME
  393.     connect -- Connect to socket.
  394.  
  395.    SYNOPSIS
  396.     return = connect( s, name, namelen )
  397.     D0                D0  A1     D1
  398.  
  399.     int connect(int, struct sockaddr *, int);
  400.  
  401.    FUNCTION
  402.     To communicate with a server using a connection-oriented protocol
  403.     (i.e. TCP), the client must connect() a socket obtained by the
  404.     client (from socket()) to the server's well-known address.  (The
  405.     server will receive (from accept()) a new socket which is connected
  406.     to the socket which the client is connect()ing to the server.)
  407.  
  408.     Clients of a connectionless server (i.e. one using UDP) can use
  409.     connect() and send() rather than always using sendto().  In this
  410.     case, no actual connection is created, the address to send to is
  411.     just stored with the socket.
  412.  
  413.     Most clients should build 'name' from a well-known port obtained from
  414.     getservbyname().  Hard-coded ports are often used in prototype
  415.     clients, but should never be used in production code.  For more
  416.     information on port numbering, see your favorite TCP/IP refrence.
  417.  
  418.    INPUTS
  419.     s        - socket descriptor.
  420.     name        - address of socket to connect 's' to.
  421.     namelen        - length of 'name.'
  422.  
  423.    RESULT
  424.     return        - 0 if successful else -1 (errno will contain the
  425.               specific error).
  426.  
  427.    EXAMPLE
  428.  
  429.    NOTES
  430.  
  431.    BUGS
  432.  
  433.    SEE ALSO
  434.     socket(), bind(), listen(), accept()
  435.  
  436. socket.library/endhostent                           socket.library/endhostent
  437.  
  438.    NAME
  439.     endhostent -- Closes the hosts file ("inet:s/hosts").
  440.  
  441.    SYNOPSIS
  442.     endhostent()
  443.  
  444.     void endhostent( void );
  445.  
  446.    FUNCTION
  447.     Closes the host file if it is open.  Only needed if sethostent()
  448.     or gethostent() have been called.
  449.  
  450.    INPUTS
  451.     None.
  452.  
  453.    RESULT
  454.     None.
  455.  
  456.    EXAMPLE
  457.  
  458.    NOTES
  459.  
  460.    BUGS
  461.  
  462.    SEE ALSO
  463.     gethostent(), gethostbyname(), gethostbyaddr(), sethostent()
  464.  
  465. socket.library/endnetent                             socket.library/endnetent
  466.  
  467.    NAME
  468.     endnetent -- Closes the networks file.
  469.  
  470.    SYNOPSIS
  471.     endnetent( )
  472.  
  473.     void endnetent( void );
  474.  
  475.    FUNCTION
  476.     Closes the host file if it is open.  This is only needed if
  477.     setnetent() or getnetent() has been called.
  478.  
  479.    INPUTS
  480.     None.
  481.  
  482.    RESULT
  483.     None.
  484.  
  485.    EXAMPLE
  486.  
  487.    NOTES
  488.  
  489.    BUGS
  490.  
  491.    SEE ALSO
  492.     getnetent(), getnetbyname(), getnetbyaddr(), setnetent()
  493.  
  494. socket.library/endprotoent                         socket.library/endprotoent
  495.  
  496.    NAME
  497.     endprotoent -- Closes the protocols file.
  498.  
  499.    SYNOPSIS
  500.     endprotoent( )
  501.  
  502.     void endprotoent( void );
  503.  
  504.    FUNCTION
  505.     Closes the protocols file if it is open.  This function is needed
  506.     only if getprotoent() or setprotoent() have been called.
  507.  
  508.    INPUTS
  509.     None.
  510.  
  511.    RESULT
  512.     None.
  513.  
  514.    EXAMPLE
  515.  
  516.    NOTES
  517.  
  518.    BUGS
  519.  
  520.    SEE ALSO
  521.     getprotoent(), setprotoent(), getprotobyname(), getprotobynumber()
  522.  
  523. socket.library/endpwent                               socket.library/endpwent
  524.  
  525.    NAME
  526.     endpwent - Closes the password file.
  527.  
  528.    SYNOPSIS
  529.     endpwent()
  530.  
  531.     void endpwent( void );
  532.  
  533.    FUNCTION
  534.     Closes the password file if it was open.
  535.  
  536.    INPUTS
  537.     None.
  538.  
  539.    RESULT
  540.     None.
  541.  
  542.    SEE ALSO
  543.     getpwent(), setpwent()
  544.  
  545. socket.library/endservent                           socket.library/endservent
  546.  
  547.    NAME
  548.     endservent -- Closes the services file.
  549.  
  550.    SYNOPSIS
  551.     endservent()
  552.  
  553.     void endservent( void );
  554.  
  555.    FUNCTION
  556.     Closes the services file if it is open.  This function is needed
  557.     only if setservent() or getservent() have been called.
  558.  
  559.    INPUTS
  560.     None.
  561.  
  562.    RESULT
  563.     None.
  564.  
  565.    EXAMPLE
  566.  
  567.    NOTES
  568.  
  569.    BUGS
  570.  
  571.    SEE ALSO
  572.     setservent(), getservent()
  573.  
  574. socket.library/FD_SET                                   socket.library/FD_SET
  575.  
  576.    NAME
  577.     FD_SET -- Macros to manipulate socket masks.
  578.  
  579.    SYNOPSIS
  580.     #include <sys/types.h>
  581.  
  582.     FD_SET(socket, mask)
  583.     FD_CLR(socket, mask)
  584.     result = FD_ISSET(socket, mask)
  585.     FD_ZERO(mask)
  586.  
  587.    FUNCTION
  588.     Type fd_set contains masks for use with sockets and select() just
  589.     like longs can contain masks for use with signals and Wait().
  590.     Unlike signal masks, you can't manipulate socket masks with boolean
  591.     operators, instead you must use the FD_*() macros.
  592.  
  593.     FD_SET() sets the "bit" for 'socket' in 'mask.'
  594.  
  595.     FD_CLR() clears the "bit" for 'socket' in 'mask.'
  596.  
  597.     FD_ISSET() returns non-zero if the "bit" for 'socket' in 'mask' is
  598.     set, else zero.
  599.  
  600.     FD_ZERO() clears all "bits" in 'mask.'  FD_ZERO should be used
  601.     to initialize an fd_set variable before it is used.
  602.  
  603.    EXAMPLE
  604.  
  605.    SEE ALSO
  606.     select(), selectwait()
  607.  
  608. socket.library/get_tz                                   socket.library/get_tz
  609.  
  610.    NAME
  611.     get_tz -- Get timezone offset.
  612.  
  613.    SYNOPSIS
  614.     offset = get_tz()
  615.     D0
  616.  
  617.     short get_tz(void);
  618.  
  619.    FUNCTION
  620.     Returns the number offset from UTC (Universal Time Coordinated,
  621.     formerly Greenwich Mean Time) in minutes west of UTC.
  622.  
  623.    RESULT
  624.     offset        - offset in minutes or -1.  An error requester
  625.               is displayed on error.
  626.  
  627.    NOTES
  628.     THIS IS AN AMIGA-ONLY FUNCTION.
  629.  
  630.     Currently the configuration information is stored in memory
  631.     in a configuration structure.  If this structure cannot be
  632.     found, it will be initialized by reading in inet:s/inet.config.
  633.     This may change in the future.
  634.  
  635.    BUGS
  636.     Does not account for daylight savings time.  If the time is really
  637.     important to you (or hosts you communicate with) you must currently
  638.     change your inet:s/inet.config for daylight savings/standard time.
  639.  
  640. socket.library/getdomainname                     socket.library/getdomainname
  641.  
  642.    NAME
  643.     getdomainname -- Get domain name.
  644.  
  645.    SYNOPSIS
  646.     return = getdomainname( name, namelen)
  647.     D0            A1    D1
  648.  
  649.     int getdomainname (char *, int);
  650.  
  651.    FUNCTION
  652.     Returns the name of the domain into the pointer specified.
  653.     Name will be null-terminated if sufficient space is available.
  654.     To find out what a domain name is, check your favorite TCP/IP
  655.     reference.
  656.  
  657.    INPUTS
  658.     name        - pointer to character buffer.
  659.     namelen        - space available in 'name.'
  660.  
  661.    RESULT
  662.     0 is returned if successful.  -1 is returned on error.
  663.  
  664.    EXAMPLE
  665.  
  666.    NOTES
  667.     There is currently no corresponding setdomainname() function.
  668.  
  669.     Currently the configuration information is stored in memory
  670.     in a configuration structure.  If this structure cannot be
  671.     found, it will be initialized by reading in inet:s/inet.config.
  672.     This may change in the future.
  673.  
  674.    BUGS
  675.  
  676.    SEE ALSO
  677.  
  678. socket.library/getgid                                   socket.library/getgid
  679.  
  680.    NAME
  681.     getgid -- Get group id.
  682.  
  683.    SYNOPSIS
  684.     #include <sys/types.h>
  685.  
  686.     gid = getgid()
  687.  
  688.     gid_t getgid (void);
  689.  
  690.    FUNCTION
  691.     returns the user's group id
  692.  
  693.    INPUTS
  694.     None.
  695.  
  696.    RESULT
  697.     gid        - group ID or -1 (on error). An error requester
  698.               will be displayed if there is a problem reading
  699.               the current configuration.
  700.  
  701.    EXAMPLE
  702.  
  703.    NOTES
  704.     This is an emulation of the Unix getgid() function.
  705.     getegid() is equivalent to getgid() on the Amiga.  Note that the
  706.     user has one primary group ID, but may have several additional
  707.     secondary group IDs which can only be obtained with getgroups().
  708.  
  709.     Currently, the configuration information is stored in memory
  710.     in a configuration structure.  If this structure cannot be
  711.     found, it will be initialized by reading in inet:s/inet.config.
  712.     This may change in the future.
  713.  
  714.    BUGS
  715.  
  716.    SEE ALSO
  717.     getgroups(), getuid()
  718.  
  719. socket.library/getgroups                             socket.library/getgroups
  720.  
  721.    NAME
  722.     getgroups -- Get group access list.
  723.  
  724.    SYNOPSIS
  725.     #include <sys/types.h>
  726.     #include <sys/param.h>
  727.  
  728.     num = getgroups(max_gids, gids)
  729.     D0        D0      A0
  730.  
  731.     int getgroups (int, gid_t *);
  732.  
  733.    FUNCTION
  734.     The array "gids" is filled with the group ids that the current user
  735.     belongs to (including the primary gid).  The list may be up to
  736.     "max_gids" long.  The actual number of gids is returned in 'num.'
  737.  
  738.    INPUTS
  739.     max_gids    - length of gids array.
  740.     gids        - gid_t array.
  741.  
  742.    RESULT
  743.     num        - the number of gids is returned if successful.
  744.               No errors are currently defined.
  745.  
  746.    EXAMPLE
  747.     gid_t gids[10];
  748.     int number_of_gids;
  749.  
  750.     number_of_gids = getgroups(10,gids);
  751.  
  752.    NOTES
  753.     Currently, the configuration information is stored in memory
  754.     in a configuration structure.  If this structure cannot be
  755.     found, it will be initialized by reading in inet:s/inet.config.
  756.     This may change in the future.
  757.  
  758.     The upper limit of groups that can be returned by getgroups() is
  759.     NGROUP (in <sys/param.h>).
  760.  
  761.    BUGS
  762.     This routine has had problems including the primary gid.
  763.     These problems should be fixed, so please report if you
  764.     see this bug.
  765.  
  766.    SEE ALSO
  767.     getgid(), getuid()
  768.  
  769. socket.library/gethostbyaddr                     socket.library/gethostbyaddr
  770.  
  771.    NAME
  772.     gethostbyaddr -- Get host entry from the hosts file.
  773.  
  774.    SYNOPSIS
  775.     #include <sys/socket.h>
  776.     #include <netdb.h>
  777.  
  778.     host = gethostbyaddr( addr, len, type )
  779.     D0                    A0    D0   D1
  780.  
  781.     struct hostent *gethostbyaddr( char *, int, int );
  782.  
  783.    FUNCTION
  784.     Opens the host file if necessary.  Finds the entry for 'addr'
  785.     and returns it in a hostent structure.  In the future, this
  786.     function will look beyond just the hosts file.
  787.  
  788.     struct    hostent {
  789.     char    *h_name;    /* official name of host */
  790.     char    **h_aliases;    /* alias list */
  791.     int    h_addrtype;    /* host address type */
  792.     int    h_length;    /* length of address */
  793.     char    **h_addr_list;    /* list of addresses from name server */
  794.     #define    h_addr    h_addr_list[0]    /* messed up for historical reasons */
  795.     };
  796.  
  797.    INPUTS
  798.     addr        - internet address, in network byte order.
  799.               (This is really a long.)
  800.     len        - sizeof(addr), usually 4
  801.     type        - usually AF_INET
  802.  
  803.    RESULT
  804.     host        - pointer to struct hostent for protocol 'addr.'
  805.               NULL on EOF or failure to open protocols file.
  806.  
  807.    EXAMPLE
  808.  
  809.    NOTES
  810.     The only type currently in use is AF_INET.
  811.  
  812.     The buffer pointed to by 'host' will be overwritten by the next
  813.     call to gethost*().
  814.  
  815.    BUGS
  816.  
  817.    SEE ALSO
  818.     gethostbyname()
  819.  
  820. socket.library/gethostbyname                     socket.library/gethostbyname
  821.  
  822.    NAME
  823.     gethostbyname -- Get host entry from the hosts file.
  824.  
  825.    SYNOPSIS
  826.     #include <sys/socket.h>
  827.     #include <netdb.h>
  828.  
  829.     host = gethostbyname( name )
  830.     D0                    A0
  831.  
  832.     struct hostent *gethostbyname( char * );
  833.  
  834.    FUNCTION
  835.     Opens the host file if necessary.  Finds the entry for "name"
  836.     and returns it in a hostent structure.  In the future, this function
  837.     will look beyond just the hosts file.
  838.  
  839.     struct    hostent {
  840.     char    *h_name;    /* official name of host */
  841.     char    **h_aliases;    /* alias list */
  842.     int    h_addrtype;    /* host address type */
  843.     int    h_length;    /* length of address */
  844.     char    **h_addr_list;    /* list of addresses from name server */
  845.     #define    h_addr    h_addr_list[0] /* messed up for historical reasons */
  846.     };
  847.  
  848.    INPUTS
  849.  
  850.    RESULT
  851.     host        - pointer to struct hostent for protocol 'name.'
  852.               NULL on EOF or failure to open protocols file.
  853.  
  854.    EXAMPLE
  855.  
  856.    NOTES
  857.     The buffer pointed to by 'host' will be overwritten by the next
  858.     call to gethost*().
  859.  
  860.    BUGS
  861.  
  862.    SEE ALSO
  863.     gethostbyaddr()
  864.  
  865. socket.library/gethostent                           socket.library/gethostent
  866.  
  867.    NAME
  868.     gethostent -- Get host entry from the hosts file ("inet:s/hosts").
  869.  
  870.    SYNOPSIS
  871.     #include <sys/types.h>
  872.     #include <sys/socket.h>
  873.     #include <netdb.h>
  874.  
  875.     host = gethostent()
  876.     D0
  877.  
  878.     struct hostent *gethostent( void );
  879.  
  880.    FUNCTION
  881.     There is normally no reason to use this function.  It is used
  882.     internally by gethostbyname() and gethostbyaddr().  It is provided
  883.     only for Un*x compatibility and even Un*x is phasing it out in
  884.     favor of other methods of name resolution.
  885.  
  886.     Opens the host file if necessary.  Returns the next entry
  887.     in the file in a hostent structure.
  888.  
  889.     struct    hostent {
  890.     char    *h_name;    /* official name of host */
  891.     char    **h_aliases;    /* alias list */
  892.     int    h_addrtype;    /* host address type */
  893.     int    h_length;    /* length of address */
  894.     char    **h_addr_list;    /* list of addresses from name server */
  895.     #define    h_addr    h_addr_list[0] /* messed up for historical reasons */
  896.     };
  897.  
  898.    INPUTS
  899.     None.
  900.  
  901.    RESULT
  902.     host        - pointer to struct hostent for next protocol.
  903.               NULL on EOF or failure to open protocols file.
  904.    EXAMPLE
  905.  
  906.    NOTES
  907.     The buffer pointed to by 'host' will be overwritten by the next
  908.     call to gethost*().
  909.  
  910.    BUGS
  911.  
  912.    SEE ALSO
  913.     sethostent(), gethostbyname(), gethostbyaddr(), endhostent()
  914.  
  915. socket.library/gethostname                         socket.library/gethostname
  916.  
  917.    NAME
  918.     gethostname -- Get the name of your Amiga.
  919.  
  920.    SYNOPSIS
  921.     return = gethostname( name, length )
  922.     D0                    A0    D0
  923.  
  924.     int gethostname (char *, int);
  925.  
  926.    FUNCTION
  927.     Copies the  null-terminated hostname to 'name'.  The hostname will
  928.     be truncated if insufficient space is available in 'name'.
  929.  
  930.    INPUTS
  931.     name        - pointer to character array.
  932.     length      - size of character array.
  933.  
  934.    RESULT
  935.     return        - 0 if successful, else -1.  The only reason for
  936.               failure will be if the configuration file is
  937.               unavailable, in which case an error requester will
  938.               be displayed.
  939.  
  940.    NOTES
  941.     Currently, the configuration information is stored in memory
  942.     in a configuration structure.  If this structure cannot be
  943.     found, it will be initialized by reading in inet:s/inet.config.
  944.     This may change in the future.
  945.  
  946.    BUGS
  947.  
  948.    SEE ALSO
  949.  
  950. socket.library/getlogin                               socket.library/getlogin
  951.  
  952.    NAME
  953.     getlogin -- Get login name.
  954.  
  955.    SYNOPSIS
  956.     name = getlogin()
  957.     D0
  958.  
  959.     char *getlogin (void);
  960.  
  961.    FUNCTION
  962.     Returns a pointer to the current user name.
  963.  
  964.    INPUTS
  965.     None.
  966.  
  967.    RESULT
  968.     name        - a pointer to the current user name or NULL to
  969.               indicate an error.  You can use this pointer for
  970.               as long as necessary, but do not write to it.
  971.  
  972.    NOTES
  973.     Currently, the configuration information is stored in memory
  974.     in a configuration structure.  If this structure cannot be
  975.     found, it will be initialized by reading in inet:s/inet.config.
  976.     This may change in the future.  There is no support for multiple
  977.     user names on a single Amiga because the Amiga OS has no concept
  978.     of multiple users.
  979.  
  980.  
  981. socket.library/getnetbyaddr                       socket.library/getnetbyaddr
  982.  
  983.    NAME
  984.     getnetbyaddr -- Get net entry from the networks file.
  985.  
  986.    SYNOPSIS
  987.     #include <netdb.h>
  988.  
  989.     net = getnetbyaddr( net, type )
  990.     D0                  D0   D1
  991.  
  992.     struct netent *getnetbyaddr( long, int );
  993.  
  994.    FUNCTION
  995.     Opens the networks file if necessary.  Returns the entry
  996.     with a matching address in a nettent structure.
  997.  
  998.     struct    netent {
  999.         char        *n_name;    /* official name of net */
  1000.         char        **n_aliases;    /* alias list */
  1001.         int        n_addrtype;    /* net address type */
  1002.         unsigned long    n_net;        /* network # */
  1003.     };
  1004.  
  1005.    INPUTS
  1006.     net        - network number.
  1007.     type        - network number type, currently AF_INET.
  1008.  
  1009.    RESULT
  1010.     net        - netent structure if succesful, NULL on EOF on
  1011.               failure to open networks file.
  1012.  
  1013.    EXAMPLE
  1014.  
  1015.    NOTES
  1016.     The netent structure is returned in a buffer that will be
  1017.     overwritten on the next call to getnet*().
  1018.  
  1019.    BUGS
  1020.  
  1021.    SEE ALSO
  1022.     getnetbyname()
  1023.  
  1024. socket.library/getnetbyname                       socket.library/getnetbyname
  1025.  
  1026.    NAME
  1027.     getnetbyname -- Get net entry from the networks file.
  1028.  
  1029.    SYNOPSIS
  1030.     #include <netdb.h>
  1031.  
  1032.     net = getnetbyname( name )
  1033.     D0                  A0
  1034.  
  1035.     struct netent *getnetbyname ( char * );
  1036.  
  1037.    FUNCTION
  1038.     Opens the networks file if necessary.  Returns the entry
  1039.     with a matching name in a nettent structure.
  1040.  
  1041.     struct    netent {
  1042.         char        *n_name;    /* official name of net */
  1043.         char        **n_aliases;    /* alias list */
  1044.         int        n_addrtype;    /* net address type */
  1045.         unsigned long    n_net;        /* network # */
  1046.     };
  1047.  
  1048.    INPUTS
  1049.     name        - network name.
  1050.  
  1051.    RESULT
  1052.     net        - netent structure if succesful, NULL on EOF on
  1053.               failure to open networks file.
  1054.  
  1055.    EXAMPLE
  1056.  
  1057.    NOTES
  1058.     The netent structure is returned in a buffer that will be
  1059.     overwritten on the next call to getnet*().
  1060.  
  1061.    BUGS
  1062.  
  1063.    SEE ALSO
  1064.     getnetbyaddr()
  1065.  
  1066. socket.library/getnetent                             socket.library/getnetent
  1067.  
  1068.    NAME
  1069.     getnetent -- Get net entry from the networks file.
  1070.  
  1071.    SYNOPSIS
  1072.     #include <netdb.h>
  1073.  
  1074.     net = getnetent( )
  1075.     D0
  1076.  
  1077.     struct netent *getnetent( void );
  1078.  
  1079.    FUNCTION
  1080.     This function should not normally be used.  It is called internally
  1081.     by getnetbyname() and getnetbyaddr().
  1082.  
  1083.     Opens the networks file if necessary.  Returns the next entry
  1084.     in the file in a nettent structure.
  1085.  
  1086.     struct    netent {
  1087.         char        *n_name;    /* official name of net */
  1088.         char        **n_aliases;    /* alias list */
  1089.         int        n_addrtype;    /* net address type */
  1090.         unsigned long    n_net;        /* network # */
  1091.     };
  1092.  
  1093.    INPUTS
  1094.     None.
  1095.  
  1096.    RESULT
  1097.     net        - netent structure if succesful, NULL on EOF on
  1098.               failure to open networks file.
  1099.  
  1100.    EXAMPLE
  1101.  
  1102.    NOTES
  1103.     The netent structure is returned in a buffer that will be
  1104.     overwritten on the next call to getnet*().
  1105.  
  1106.    BUGS
  1107.  
  1108.    SEE ALSO
  1109.     setnetent(), getnetbyname(), getnetbyaddr(), endnetent()
  1110.  
  1111. socket.library/getpeername                         socket.library/getpeername
  1112.  
  1113.    NAME
  1114.     getpeername -- Get name of connected peer.
  1115.  
  1116.    SYNOPSIS
  1117.     return = getpeername( s, name, namelen )
  1118.     D0                    D0 A0    A1
  1119.  
  1120.     int getpeername( int, struct sockaddr *, int * );
  1121.  
  1122.    FUNCTION
  1123.     For every connected socket, there is a socket at the other end
  1124.     of the connection.  To determine the address of the socket at the
  1125.     other end of a connection, pass getpeername() the socket on your
  1126.     end.  'Namelen' should be initialized to the amount of space pointed
  1127.     to by 'name.'  The actual size of 'name' will be returned in
  1128.     'namelen.'
  1129.  
  1130.    INPUTS
  1131.     s        - socket descriptor.
  1132.     name        - pointer to a struct sockaddr.
  1133.     namelen        - initialized to size of 'name.' On return this
  1134.               contains the actual sizeof(name)
  1135.  
  1136.    RESULT
  1137.     return        - 0 if successful else -1 (errno will contain the
  1138.               specific error).
  1139.  
  1140.    EXAMPLE
  1141.  
  1142.    NOTES
  1143.  
  1144.    BUGS
  1145.  
  1146.    SEE ALSO
  1147.     bind(), accept(), getsockname()
  1148.  
  1149. socket.library/getprotobyname                   socket.library/getprotobyname
  1150.  
  1151.    NAME
  1152.     getprotobyname -- find a protocol entry by name
  1153.  
  1154.    SYNOPSIS
  1155.     #include <netdb.h>
  1156.  
  1157.     proto = getprotobyname( name )
  1158.     D0                      A0
  1159.  
  1160.     struct protoent *getprotobyname( char * );
  1161.  
  1162.    FUNCTION
  1163.     Opens the protocols file if necessary.  Returns the entry
  1164.     with a matching name in a protoent structure.
  1165.  
  1166.     struct    protoent {
  1167.         char    *p_name;        /* official protocol name */
  1168.         char    **p_aliases;    /* alias list */
  1169.         int     p_proto;        /* protocol # */
  1170.     };
  1171.  
  1172.  
  1173.    INPUTS
  1174.     name        - name of prototype to return.
  1175.  
  1176.    RESULT
  1177.     proto        - pointer to struct protoent for protocol 'name.'
  1178.               NULL on EOF or failure to open protocols file.
  1179.  
  1180.    EXAMPLE
  1181.  
  1182.    NOTES
  1183.     The protoent structure is returned in a buffer that will be
  1184.     overwritten on the next call to getproto*()
  1185.  
  1186.    BUGS
  1187.  
  1188.    SEE ALSO
  1189.     getprotobynumber()
  1190.  
  1191. socket.library/getprotobynumber               socket.library/getprotobynumber
  1192.  
  1193.    NAME
  1194.     getprotobynumber -- find a protocol entry by number
  1195.  
  1196.    SYNOPSIS
  1197.     #include <netdb.h>
  1198.  
  1199.     proto = getprotobynumber( proto )
  1200.     D0                        D0
  1201.  
  1202.     struct protoent *getprotobynumber( int );
  1203.  
  1204.    FUNCTION
  1205.     Opens the protocols file if necessary.  Returns the entry
  1206.     with a matching protocol number in a protoent structure.
  1207.  
  1208.     struct    protoent {
  1209.         char    *p_name;        /* official protocol name */
  1210.         char    **p_aliases;    /* alias list */
  1211.         int     p_proto;        /* protocol # */
  1212.     };
  1213.  
  1214.  
  1215.    INPUTS
  1216.     proto        - number of prototype to return.
  1217.  
  1218.    RESULT
  1219.     proto        - pointer to struct protoent for protocol 'number.'
  1220.               NULL on EOF or failure to open protocols file.
  1221.  
  1222.    EXAMPLE
  1223.  
  1224.    NOTES
  1225.     The protoent structure is returned in a buffer that will be
  1226.     overwritten on the next call to getproto*()
  1227.  
  1228.    BUGS
  1229.  
  1230.    SEE ALSO
  1231.     getprotobyname()
  1232.  
  1233. socket.library/getprotoent                         socket.library/getprotoent
  1234.  
  1235.    NAME
  1236.     getprotoent -- Get a protocol entry from the protocols file.
  1237.  
  1238.    SYNOPSIS
  1239.     #include <netdb.h>
  1240.  
  1241.     proto = getprotoent ( )
  1242.  
  1243.     struct protoent *getprotoent ( void );
  1244.  
  1245.    FUNCTION
  1246.     There is normally no reason to use this function.  It is used
  1247.     internally by getprotobyname() and getprotobynumber().  It is
  1248.     provided only for Un*x compatibility.
  1249.  
  1250.     Opens the protocols file if necessary.  Returns the next entry
  1251.     in the file in a protoent structure.
  1252.  
  1253.     struct    protoent {
  1254.         char    *p_name;        /* official protocol name */
  1255.         char    **p_aliases;    /* alias list */
  1256.         int     p_proto;        /* protocol # */
  1257.     };
  1258.  
  1259.  
  1260.    INPUTS
  1261.     None.
  1262.  
  1263.    RESULT
  1264.     proto        - NULL on EOF or failure to open protocols file.
  1265.  
  1266.    EXAMPLE
  1267.  
  1268.    NOTES
  1269.     The protoent structure is returned in a buffer that will be
  1270.     overwritten on the next call to getproto*()
  1271.  
  1272.    BUGS
  1273.  
  1274.    SEE ALSO
  1275.     getprotobyname(), getprotobynumber(), setprotoent(), endprotoent()
  1276.  
  1277. socket.library/getpwent                               socket.library/getpwent
  1278.  
  1279.    NAME
  1280.     getpwent -- Read the next line in the password file.
  1281.  
  1282.    SYNOPSIS
  1283.     passwd = getpwent()
  1284.     D0
  1285.  
  1286.     struct passwd *getpwent( void ) ;
  1287.  
  1288.    FUNCTION
  1289.     There is usually no reason to call this function directly.  It
  1290.     is called internally by getpwuid() and getpwnam().  It is provided
  1291.     only for Un*x compatibility.
  1292.  
  1293.     Opens the password file if necessary.  Returns the next entry
  1294.     in the file in a passwd structure.
  1295.  
  1296.     struct passwd {
  1297.         char    *pw_name;
  1298.         char    *pw_dir;
  1299.         char    *pw_passwd;
  1300.         char    *pw_gecos;
  1301.         uid_t    pw_uid;
  1302.         gid_t    pw_gid;
  1303.         char    *pw_shell;        /* currently unused */
  1304.         char    *pw_comment;
  1305.     };
  1306.  
  1307.    INPUTS
  1308.     None.
  1309.  
  1310.    RESULT
  1311.     passwd         - a pointer to a filled in passwd structure
  1312.               if successful, else NULL.
  1313.  
  1314.    SEE ALSO
  1315.     getpwuid(), getpwnam(), setpwent(), endpwent()
  1316.  
  1317. socket.library/getpwnam                               socket.library/getpwnam
  1318.  
  1319.    NAME
  1320.     getpwnam -- Search user database for a particular name.
  1321.  
  1322.    SYNOPSIS
  1323.     #include <pwd.h>
  1324.  
  1325.     passwd = getpwnam( name )
  1326.     D0                  A0
  1327.  
  1328.     struct passwd *getpwnam( char * );
  1329.  
  1330.    FUNCTION
  1331.     getpwnam() returns a pointer to a passwd structure. The passwd
  1332.     structure fields are filled in from the fields contained in
  1333.     one line of the password file.
  1334.  
  1335.    INPUTS
  1336.     name         - user name of passwd entry to look up.
  1337.  
  1338.    RESULT
  1339.     passwd         - a pointer to a passwd struct with its elements
  1340.               filled in from the passwd file.
  1341.  
  1342.         struct passwd {
  1343.             char    *pw_name;
  1344.             char    *pw_dir;
  1345.             char    *pw_passwd;
  1346.             char    *pw_gecos;
  1347.             uid_t    pw_uid;
  1348.             gid_t    pw_gid;
  1349.             char    *pw_shell;    /* currently unused  */
  1350.             char    *pw_comment;
  1351.         };
  1352.  
  1353.    NOTES
  1354.     The passwd structure is returned in a buffer that will be
  1355.     overwritten on the next call to getpw*().
  1356.  
  1357.    SEE ALSO
  1358.     getpwuid()
  1359. socket.library/getpwuid                               socket.library/getpwuid
  1360.  
  1361.    NAME
  1362.     getpwuid -- Search user database for a particular uid.
  1363.  
  1364.    SYNOPSIS
  1365.     #include <pwd.h>
  1366.  
  1367.     passwd = getpwuid( uid )
  1368.     D0                 D1
  1369.  
  1370.     struct passwd *getpwuid( uid_t );
  1371.  
  1372.    FUNCTION
  1373.     getpwuid() returns a pointer to a passwd structure.  The passwd
  1374.     structure fields are filled in from the fields contained in
  1375.     one line of the password file.
  1376.  
  1377.    INPUTS
  1378.     uid        - uid of passwd entry to look up.
  1379.  
  1380.    RESULT
  1381.     passwd         - a pointer to a passwd struct with its elements
  1382.               filled in from the passwd file.
  1383.  
  1384.         struct passwd {
  1385.             char    *pw_name;
  1386.             char    *pw_dir;
  1387.             char    *pw_passwd;
  1388.             char    *pw_gecos;
  1389.             uid_t    pw_uid;
  1390.             gid_t    pw_gid;
  1391.             char    *pw_shell;    /* currently unused */
  1392.             char    *pw_comment;
  1393.         };
  1394.  
  1395.    NOTES
  1396.     The passwd structure is returned in a buffer that will be
  1397.     overwritten on the next call to getpw*().
  1398.  
  1399.    SEE ALSO
  1400.     getpwnam()
  1401.  
  1402. socket.library/getservbyname                     socket.library/getservbyname
  1403.  
  1404.    NAME
  1405.     getservbyname -- Find a service entry by name.
  1406.  
  1407.    SYNOPSIS
  1408.     #include <netdb.h>
  1409.  
  1410.     serv = getservbyname( name, proto )
  1411.     D0                    A0    A1
  1412.  
  1413.     struct servent *getservbyname( char *, char * );
  1414.  
  1415.    FUNCTION
  1416.     Opens the services file and finds the service with the matching
  1417.     name and protocol.
  1418.  
  1419.     struct    servent {
  1420.         char    *s_name;    /* official service name */
  1421.         char    **s_aliases;    /* alias list */
  1422.         int    s_port;        /* port # */
  1423.         char    *s_proto;    /* protocol to use */
  1424.     };
  1425.  
  1426.  
  1427.    INPUTS
  1428.     name        - name of service to look up.
  1429.     proto        - protocol of service to look up.
  1430.  
  1431.    RESULT
  1432.     serv        - pointer to struct servent for service 'name.'
  1433.               NULL on EOF or failure to open protocols file.
  1434.  
  1435.    EXAMPLE
  1436.  
  1437.    NOTES
  1438.     The servent structure is returned in a buffer that will be
  1439.     overwritten on the next call to getserv*().
  1440.  
  1441.    BUGS
  1442.  
  1443.    SEE ALSO
  1444.     getservent(), getservbyport()
  1445.  
  1446. socket.library/getservbyport                     socket.library/getservbyport
  1447.  
  1448.    NAME
  1449.     getservbyport -- Find a service entry by port.
  1450.  
  1451.    SYNOPSIS
  1452.     #include <netdb.h>
  1453.  
  1454.     serv = getservbyport( port, proto )
  1455.     D0                    D0    A0
  1456.  
  1457.     struct servent *getservbyport( u_short, char * );
  1458.  
  1459.    FUNCTION
  1460.     Opens the services file and finds the service with the matching
  1461.     port and protocol.
  1462.  
  1463.     struct    servent {
  1464.         char    *s_name;    /* official service name */
  1465.         char    **s_aliases;    /* alias list */
  1466.         int    s_port;        /* port # */
  1467.         char    *s_proto;    /* protocol to use */
  1468.     };
  1469.  
  1470.    INPUTS
  1471.  
  1472.    RESULT
  1473.     serv        - pointer to struct servent for service 'name.'
  1474.               NULL on EOF or failure to open protocols file.
  1475.  
  1476.    EXAMPLE
  1477.  
  1478.    NOTES
  1479.     The servent structure is returned in a buffer that will be
  1480.     overwritten on the next call to getserv*().
  1481.  
  1482.    BUGS
  1483.  
  1484.    SEE ALSO
  1485.     getservent(), getservbyname()
  1486.  
  1487. socket.library/getservent                           socket.library/getservent
  1488.  
  1489.    NAME
  1490.     getservent -- Get a service entry from the services file.
  1491.  
  1492.    SYNOPSIS
  1493.     #include <netdb.h>
  1494.  
  1495.     serv = getservent( void )
  1496.     D0
  1497.  
  1498.     struct servent *getservent( void );
  1499.  
  1500.    FUNCTION
  1501.     There is normally no reason to use this function.  It is used
  1502.     internally by getservbyname() and getservbyport().  It is
  1503.     provided only for Un*x compatibility.
  1504.  
  1505.     Opens the services file if necessary.  Returns the next entry
  1506.     in the file in a servent structure.
  1507.  
  1508.     struct    servent {
  1509.         char    *s_name;    /* official service name */
  1510.         char    **s_aliases;    /* alias list */
  1511.         int    s_port;        /* port # */
  1512.         char    *s_proto;    /* protocol to use */
  1513.     };
  1514.  
  1515.    INPUTS
  1516.     None.
  1517.  
  1518.    RESULT
  1519.     serv        - pointer to struct servent for next service.
  1520.               NULL on EOF or failure to open protocols file.
  1521.  
  1522.    EXAMPLE
  1523.  
  1524.    NOTES
  1525.     The servent structure is returned in a buffer that will be
  1526.     overwritten on the next call to getserv*()
  1527.  
  1528.    BUGS
  1529.  
  1530.    SEE ALSO
  1531.     setservent(), getservbyname(), getservbyport(), endservent()
  1532.  
  1533. socket.library/getsockname                         socket.library/getsockname
  1534.  
  1535.    NAME
  1536.     getsockname -- Get the name of a socket.
  1537.  
  1538.    SYNOPSIS
  1539.     return = getsockname( s, name, namelen )
  1540.     D0                    D0 A0    A1
  1541.  
  1542.     int getsockname( int, struct sockaddr *, int * );
  1543.  
  1544.    FUNCTION
  1545.     Returns the name (address) of the specified socket.  'Namelen'
  1546.     should be initialized to the amount of space pointed to by 'name.'
  1547.     The actual size of 'name' will be returned in 'namelen.'
  1548.  
  1549.    INPUTS
  1550.     s        - socket descriptor.
  1551.     name        - socket name.
  1552.     namelen        - size of 'name' (in bytes).
  1553.  
  1554.    RESULT
  1555.     return        - 0 if successful else -1 (errno will be set to
  1556.               one of the following error codes:
  1557.                EBADF        invalid socket
  1558.  
  1559.    EXAMPLE
  1560.  
  1561.    NOTES
  1562.  
  1563.    BUGS
  1564.  
  1565.    SEE ALSO
  1566.     bind(), getpeername()
  1567.  
  1568. socket.library/getsockopt                           socket.library/getsockopt
  1569.  
  1570.    NAME
  1571.     getsockopt -- Get socket options.
  1572.  
  1573.    SYNOPSIS
  1574.     return = getsockopt( s, level, optname, optval, optlenp )
  1575.     D0                   D0 D1     D2       A0      A1
  1576.  
  1577.     int getsockopt( int, int, int, char *, int * );
  1578.  
  1579.    FUNCTION
  1580.     Gets the option specified by 'optname' for socket 's.'
  1581.     This is an advanced function.  See the "sys/socket.h" header and
  1582.     your favorite TCP/IP reference for more information on options.
  1583.  
  1584.    INPUTS
  1585.     s        - socket descriptor.
  1586.     level        - protocol level.  Valid levels are:
  1587.               IPPROTO_IP               IP options
  1588.               IPPROTO_TCP              TCP options
  1589.               SOL_SOCKET               socket options
  1590.     optname        - option name.
  1591.     optval        - pointer to the buffer which will contain the
  1592.               answer.
  1593.     optlen        - initially sizeof(optval). reset to new value
  1594.               on return
  1595.  
  1596.    RESULT
  1597.     return        - 0 if successful else -1 (errno will contain the
  1598.               specific error).
  1599.  
  1600.    EXAMPLE
  1601.  
  1602.    NOTES
  1603.  
  1604.    BUGS
  1605.  
  1606.    SEE ALSO
  1607.     setsockopt()
  1608.  
  1609. socket.library/getuid                                   socket.library/getuid
  1610.  
  1611.    NAME
  1612.     getuid  -- Get user id.
  1613.  
  1614.    SYNOPSIS
  1615.     #include <sys/types.h>
  1616.  
  1617.     uid = getuid()
  1618.     D0
  1619.  
  1620.     uid_t getuid (void);
  1621.  
  1622.    FUNCTION
  1623.     Returns the user id.
  1624.  
  1625.    INPUTS
  1626.     None.
  1627.  
  1628.    RESULT
  1629.     uid        - user ID or -1 (on error).  An error requester will
  1630.               be displayed if there is a problem reading the
  1631.               current configuration.
  1632.  
  1633.    EXAMPLE
  1634.  
  1635.    NOTES
  1636.     This is an emulation of the Unix getuid() function.
  1637.     geteuid() is equivalent to getuid() on the Amiga.
  1638.  
  1639.     Currently, the configuration information is stored in memory
  1640.     in a configuration structure.  If this structure cannot be
  1641.     found, it will be initialized by reading in inet:s/inet.config.
  1642.     This may change in the future.  There is no support for multiple
  1643.     user IDs on a single Amiga because the Amiga OS has no concept
  1644.     of multiple users.
  1645.  
  1646.    BUGS
  1647.  
  1648.    SEE ALSO
  1649.     getgid(), getgroups()
  1650.  
  1651. socket.library/getumask                               socket.library/getumask
  1652.  
  1653.    NAME
  1654.     getumask -- Get user file creation mask.
  1655.  
  1656.    SYNOPSIS
  1657.     #include <sys/types.h>
  1658.  
  1659.     umask = getumask()
  1660.     D0
  1661.  
  1662.     mode_t getumask (void);
  1663.  
  1664.    FUNCTION
  1665.     Returns the umask.
  1666.  
  1667.    RESULT
  1668.     -1 will be returned and an error message will be displayed
  1669.     if there is a problem reading the current configuration.
  1670.  
  1671.    EXAMPLE
  1672.  
  1673.    NOTES
  1674.     THIS IS AN AMIGA-SPECIFIC FUNCTION.  It is not a standard Unix
  1675.     function.  See umask().
  1676.  
  1677.     Currently, the configuration information is stored in memory
  1678.     in a configuration structure.  If this structure cannot be
  1679.     found, it will be initialized by reading in inet:s/inet.config.
  1680.     This may change in the future.
  1681.  
  1682.    BUGS
  1683.  
  1684.    SEE ALSO
  1685.     umask()
  1686.  
  1687. socket.library/inet_addr                             socket.library/inet_addr
  1688.  
  1689.    NAME
  1690.     inet_addr -- make internet address from string
  1691.  
  1692.    SYNOPSIS
  1693.     #include <sys/types.h>
  1694.     #include <sys/socket.h>
  1695.     #include <netinet/in.h>
  1696.  
  1697.     addr = inet_addr( string )
  1698.     D0                A1
  1699.  
  1700.     u_long inet_addr ( char * );
  1701.  
  1702.    FUNCTION
  1703.     Converts a string to an internet address.  All internet addresses
  1704.     are in network order.
  1705.  
  1706.    INPUTS
  1707.     string        address string. "123.45.67.89" for example
  1708.  
  1709.    RESULT
  1710.     A long representing the network address in network byte order.
  1711.  
  1712.     INADDR_NONE is returned if input is invalid.
  1713.  
  1714.    EXAMPLE
  1715.  
  1716.    NOTES
  1717.  
  1718.    BUGS
  1719.  
  1720.    SEE ALSO
  1721.  
  1722. socket.library/inet_lnaof                           socket.library/inet_lnaof
  1723.  
  1724.    NAME
  1725.     inet_lnaof -- give the local network address
  1726.  
  1727.    SYNOPSIS
  1728.     #include <sys/types.h>
  1729.     #include <sys/socket.h>
  1730.     #include <netinet/in.h>
  1731.  
  1732.     addr = inet_lnaof( in )
  1733.     D0                 D1
  1734.  
  1735.     int inet_lnaof ( struct in_addr );
  1736.  
  1737.    FUNCTION
  1738.     Returns the local network address.
  1739.  
  1740.    INPUTS
  1741.        in        - struct in_addr to find local network part of.
  1742.  
  1743.     struct in_addr {
  1744.         u_long s_addr; /* a long containing the internet address */
  1745.     };
  1746.  
  1747.    RESULT
  1748.     addr        -  the local network address portion of 'in.'
  1749.  
  1750.    EXAMPLE
  1751.  
  1752.    NOTES
  1753.     'in' is *NOT* a pointer to a struct in_addr, it IS a structure.
  1754.     It is a 4-byte structure and is a passed as a structure (rather
  1755.     than a long or pointer to a structure) for historical reasons.
  1756.  
  1757.    RESULT
  1758.  
  1759.    EXAMPLE
  1760.  
  1761.    NOTES
  1762.  
  1763.    BUGS
  1764.  
  1765.    SEE ALSO
  1766.     inet_addr(), inet_makeaddr(), inet_netof()
  1767.  
  1768. socket.library/inet_makeaddr                     socket.library/inet_makeaddr
  1769.  
  1770.    NAME
  1771.     inet_makeaddr -- make internet address from network and host
  1772.  
  1773.    SYNOPSIS
  1774.     #include <sys/types.h>
  1775.     #include <sys/socket.h>
  1776.     #include <netinet/in.h>
  1777.  
  1778.     addr = inet_makeaddr( net, lna )
  1779.     D0                    D0   D1
  1780.  
  1781.     struct in_addr inet_makeaddr( int, int );
  1782.  
  1783.    FUNCTION
  1784.      Formulate an Internet address from network + host.  Used in
  1785.     building addresses stored in the ifnet structure.
  1786.  
  1787.     'in' is *NOT* a pointer to a struct in_addr, it IS a structure.
  1788.     It is a 4-byte structure and is a passed as a structure (rather
  1789.     than a long or pointer to a structure) for historical reasons.
  1790.     See NOTES.
  1791.  
  1792.  
  1793.    INPUTS
  1794.     net        - network number in local integer format.
  1795.     lna        - local node address in local integer format.
  1796.  
  1797.    RESULT
  1798.        in        - struct in_addr.
  1799.  
  1800.     struct in_addr {
  1801.         u_long s_addr; /* a long containing the internet address */
  1802.     };
  1803.  
  1804.    EXAMPLE
  1805.  
  1806.    NOTES
  1807.     'in' is *NOT* a pointer to a struct in_addr, it IS a structure.
  1808.     It is a 4-byte structure and is a passed as a structure (rather
  1809.     than a long or pointer to a structure) for historical reasons.
  1810.  
  1811.    BUGS
  1812.  
  1813.    SEE ALSO
  1814.     inet_addr(), inet_lnaof(), inet_netof()
  1815.  
  1816. socket.library/inet_netof                           socket.library/inet_netof
  1817.  
  1818.    NAME
  1819.     inet_netof -- give the network number of an address
  1820.  
  1821.    SYNOPSIS
  1822.     #include <sys/types.h>
  1823.     #include <sys/socket.h>
  1824.     #include <netinet/in.h>
  1825.  
  1826.     net = inet_netof( in )
  1827.     D0          D1
  1828.  
  1829.     int inet_netof( struct in_addr );
  1830.  
  1831.    FUNCTION
  1832.     Returns the network number.
  1833.  
  1834.    INPUTS
  1835.        in        - struct in_addr to find network part of.
  1836.  
  1837.     struct in_addr {
  1838.         u_long s_addr; /* a long containing the internet address */
  1839.     };
  1840.  
  1841.    RESULT
  1842.     net        - network part of 'in.'
  1843.    EXAMPLE
  1844.  
  1845.    NOTES
  1846.     'in' is *NOT* a pointer to a struct in_addr, it IS a structure.
  1847.     It is a 4-byte structure and is a passed as a structure (rather
  1848.     than a long or pointer to a structure) for historical reasons.
  1849.  
  1850.    BUGS
  1851.  
  1852.    SEE ALSO
  1853.     inet_addr(), inet_makeaddr(), inet_lnaof()
  1854.  
  1855. socket.library/inet_network                       socket.library/inet_network
  1856.  
  1857.    NAME
  1858.     inet_network -- make network number from string
  1859.  
  1860.    SYNOPSIS
  1861.     #include <sys/types.h>
  1862.     #include <sys/socket.h>
  1863.     #include <netinet/in.h>
  1864.  
  1865.     net = inet_network( string )
  1866.     D0            A1
  1867.  
  1868.     int inet_network( char * );
  1869.  
  1870.    FUNCTION
  1871.     Converts a string to an network number if the string contains the
  1872.     dotted-decimal representation of a network number. All network
  1873.     numbers are in network order.
  1874.  
  1875.    INPUTS
  1876.     string        - network string. "123.45.67.89" for example.
  1877.  
  1878.    RESULT
  1879.     net        - INADDR_NONE is returned if input is invalid, else
  1880.               the network number corresponding to 'string.'
  1881.  
  1882.    EXAMPLE
  1883.  
  1884.    NOTES
  1885.  
  1886.    BUGS
  1887.  
  1888.    SEE ALSO
  1889.  
  1890. socket.library/inet_ntoa                             socket.library/inet_ntoa
  1891.  
  1892.    NAME
  1893.     inet_ntoa -- turn internet address into string
  1894.  
  1895.    SYNOPSIS
  1896.     #include <sys/types.h>
  1897.     #include <sys/socket.h>
  1898.     #include <netinet/in.h>
  1899.  
  1900.     string = inet_ntoa( in )
  1901.     D0                  D1
  1902.  
  1903.     char *inet_ntoa ( struct in_addr );
  1904.  
  1905.    FUNCTION
  1906.     Converts an internet address to an ASCII string in the format
  1907.     "a.b.c.d" (dotted-decimal notation).
  1908.  
  1909.    INPUTS
  1910.        in        - struct in_addr.
  1911.  
  1912.     struct in_addr {
  1913.         u_long s_addr; /* a long containing the internet address */
  1914.     };
  1915.  
  1916.    RESULT
  1917.     Pointer to a string containing the ASCII ethernet address.
  1918.     For example, if in.s_addr = 0xc009d203 then a pointer
  1919.     to the string "192.9.210.3" is returned.
  1920.  
  1921.    NOTES
  1922.     The result points to a static buffer that is overwritten
  1923.     with each call.
  1924.  
  1925.     'in' is *NOT* a pointer to a struct in_addr, it IS a structure.
  1926.     It is a 4-byte structure and is a passed as a structure (rather
  1927.     than a long or pointer to a structure) for historical reasons.
  1928.  
  1929.    BUGS
  1930.  
  1931.    SEE ALSO
  1932.  
  1933. socket.library/listen                                   socket.library/listen
  1934.  
  1935.    NAME
  1936.     listen -- Indicate willingness to accept() connections.
  1937.  
  1938.    SYNOPSIS
  1939.     return = listen( s, backlog )
  1940.     D0         D0 D1
  1941.  
  1942.     int listen(int, int);
  1943.  
  1944.    FUNCTION
  1945.     This function is used for a connection-oriented server (i.e. one
  1946.     using the TCP protocol)    to indicate that it is waiting to receive
  1947.     connections.  It is usually executed after socket() and bind(), and
  1948.     before accept().
  1949.  
  1950.    INPUTS
  1951.     s        - socket descriptor.
  1952.     backlog        - max number of connection requests to queue
  1953.               (usually 5).
  1954.  
  1955.    RESULT
  1956.     return        - 0 is returned if successful, else  -1. On error,
  1957.               errno will be set to one of the following:
  1958.  
  1959.     EBADF        - s is not a valid descriptor
  1960.     ENOTSOCK    - s is not a socket
  1961.     ECONNREFUSED    - connection refused, normally because the queue
  1962.               is full
  1963.     EOPNOTSUPP    - s is a socket type which does not support this
  1964.               operation.  s must be type SOCK_STREAM.
  1965.  
  1966.    BUGS
  1967.     'backlog' is currently limited to 5.
  1968.  
  1969.    SEE ALSO
  1970.     accept(), bind(), connect(), socket()
  1971.  
  1972. socket.library/rcmd                                       socket.library/rcmd
  1973.  
  1974.    NAME
  1975.     rcmd - Allow superuser to execute commands on remote machines
  1976.  
  1977.    SYNOPSIS
  1978.     rem = rcmd( ahost, inport, luser, ruser, cmd, fd2p )
  1979.     D0          D0       D1       A0     A1     A2   D2
  1980.  
  1981.     int rcmd( char **, u_short, char *, char *, char *, int *);
  1982.  
  1983.    FUNCTION
  1984.     This function is used by rsh and rcp to communicate with rshd.
  1985.  
  1986.     The rcmd subroutine looks up the host *ahost using gethostbyname,
  1987.     returning (-1) if the host does not exist. Otherwise *ahost is
  1988.     set to the standard name of the host and a connection is
  1989.     established to a server residing at the well-known Internet port
  1990.     inport.
  1991.  
  1992.     If the call succeeds, a socket of type SOCK_STREAM is returned to
  1993.     the caller and given to the remote command as stdin and stdout.
  1994.     If fd2p is nonzero, then an auxiliary channel to a control
  1995.     process will be set up, and a descriptor for it will be placed in
  1996.     *fd2p. The control process will return diagnostic output from the
  1997.     command (unit 2) on this channel, and will also accept bytes on
  1998.     this channel as being UNIX signal numbers, to be forwarded to the
  1999.     process group of the command. If fd2p is 0, then the stderr (unit
  2000.     2 of the remote command) will be made the same as the stdout and
  2001.     no provision is made for sending arbitrary signals to the remote
  2002.     process, although you may be able to get its attention by using
  2003.     out-of-band data.
  2004.  
  2005.    INPUTS
  2006.     ahost          - pointer to a pointer to a host name.
  2007.     inport         - an Internet port.
  2008.     luser          - the local user's name.
  2009.     ruser          - the remote user's name.
  2010.     cmd            - the command string to be executed.
  2011.     fd2p           - a flag telling whether to use an auxillary channel.
  2012.  
  2013.    RESULT
  2014.     rem         - socket of type SOCK_STREAM if successful, else -1.
  2015.  
  2016.  
  2017. socket.library/reconfig                               socket.library/reconfig
  2018.  
  2019.    NAME
  2020.     reconfig - re-initialize the internal configuration structure
  2021.  
  2022.    SYNOPSIS
  2023.     return = reconfig()
  2024.     D0
  2025.  
  2026.     BOOL reconfig( VOID ) ;
  2027.  
  2028.    FUNCTION
  2029.     Causes the socket library to read the inet:s/inet.config file.  
  2030.     This is useful for when you have changed an entry in the file 
  2031.     and need the system to recognize the change without a system 
  2032.     reboot.
  2033.  
  2034.    INPUTS
  2035.     None
  2036.  
  2037.    RESULT
  2038.     Boolean return - TRUE upon success, FALSE upon error
  2039.  
  2040.    NOTES
  2041.     Make -no- assumptions about how this works internally. The current
  2042.     mechanism is in transition and is guaranteed to change.
  2043.  
  2044.    BUGS
  2045.  
  2046.    SEE ALSO
  2047.  
  2048. socket.library/recv                                       socket.library/recv
  2049.  
  2050.    NAME
  2051.     recv, recvfrom, recvmsg -- Receive a message from a socket.
  2052.  
  2053.    SYNOPSIS
  2054.     #include <sys/types.h>
  2055.     #include <sys/socket.h>
  2056.  
  2057.     numbytes = recv( s, buf, len, flags )
  2058.     D0               D0 A0   D1   D2
  2059.  
  2060.     numbytes = recvfrom( s, buf, len, flags, from, fromlen )
  2061.     D0                   D0 A0    D1  D2     A1    A2
  2062.  
  2063.     numbytes = recvmsg( s, msg, flags )
  2064.     D0                  D0 A0   D1
  2065.  
  2066.     int recv(int, char *, int, int )
  2067.     int recvfrom( int, char *, int, int, struct sockaddr *, int *)
  2068.     int recvmsg(int, struct msghdr *, int )
  2069.  
  2070.    FUNCTION
  2071.     recv() is used to receive messages on an already connect()ed
  2072.     socket.
  2073.  
  2074.     recvfrom() receives data from a socket whether it is in a connected
  2075.     state or not.
  2076.  
  2077.     recvmsg() is the most general of the recv calls and is for advanced
  2078.     use.
  2079.  
  2080.     If no data is available, these calls block unless the socket is
  2081.     set to nonblocking in which case (-1) is returned with errno set
  2082.     to EWOULDBLOCK.
  2083.  
  2084.    INPUTS
  2085.     s           - a socket descriptor.
  2086.     buf         - the buffer into which the incoming data will be
  2087.               placed.
  2088.     len         - the size of the buffer.
  2089.     flags       - select options (MSG_OOB, MSG_PEEK).
  2090.     from        - a pointer to a sockaddr structure.
  2091.     fromlen     - Length of the 'from' buffer.
  2092.     msg         - pointer to a struct msghdr, defined in
  2093.               "sys/socket.h."
  2094.  
  2095.    RESULT
  2096.     numbytes     - number of bytes read if successful else -1.
  2097.  
  2098.    NOTES
  2099.     'fromlen' is passed with the length of the 'from' buffer.  If 'from'
  2100.     is non-zero, the structure will be filled with the source address
  2101.     and fromlen will be filled in to represent the size of the actual
  2102.     address stored in 'from'.
  2103.  
  2104.    SEE ALSO
  2105.     send(), socket(), connect(), bind(), listen(), accept()
  2106.  
  2107. socket.library/s_close                                 socket.library/s_close
  2108.  
  2109.    NAME
  2110.     s_close -- Close a socket.
  2111.  
  2112.    SYNOPSIS
  2113.     status = s_close( socket ) ;
  2114.     D0                D0
  2115.  
  2116.     int s_close( int ) ;
  2117.  
  2118.    FUNCTION
  2119.        This function closes a socket.
  2120.  
  2121.    INPUTS
  2122.        unit        - socket number.
  2123.  
  2124.    RESULT
  2125.     status          - 0 if successful, else -1.
  2126.  
  2127.    EXAMPLE
  2128.  
  2129.    NOTES
  2130.     s_close() must always be used to close a socket.  This shared
  2131.     library does not know about filehandles or file descriptors.
  2132.  
  2133.    BUGS
  2134.  
  2135.    SEE ALSO
  2136.     socket()
  2137.  
  2138. socket.library/s_dev_list                           socket.library/s_dev_list
  2139.  
  2140.    NAME
  2141.     s_dev_list -- set device list
  2142.  
  2143.    SYNOPSIS
  2144.     s_dev_list( res, size);
  2145.                 D0    D1
  2146.  
  2147.     void s_dev_list( u_long, int );
  2148.  
  2149.    FUNCTION
  2150.     This function is intended to assist in the building of
  2151.     Unix compatibility libraries.  s_dev_list() pass a pointer
  2152.     to an array that can be used to tell the socket library
  2153.     what socket numbers should not be used.  The socket library
  2154.     will not create a socket number 'X' if reserved[X] is set.
  2155.     The socket library will never change the contents of the
  2156.     reserved array.
  2157.  
  2158.    INPUTS
  2159.     res        - pointer to device table
  2160.     size        - size of each entry in the device table
  2161.  
  2162.    EXAMPLE
  2163.  
  2164.    NOTES
  2165.     This is a kludge to get around some of the problems caused because
  2166.     a socket is not a file descriptor or a filehandle.
  2167.     If you don't understand why this function is here, you probably
  2168.     don't need it. 
  2169.     
  2170.  
  2171. socket.library/s_getsignal                         socket.library/s_getsignal
  2172.  
  2173.    NAME
  2174.     s_getsignal -- Get a network signal bit.
  2175.  
  2176.    SYNOPSIS
  2177.     signal = s_getsignal( type );
  2178.     D0                    D1
  2179.  
  2180.     BYTE s_getsignal( UWORD );
  2181.  
  2182.    FUNCTION
  2183.     This function returns a socket signal.  The socket signal can be
  2184.     used to Wait() on an event for the shared socket library.  The
  2185.     following signal types are supported:
  2186.  
  2187.     SIGIO   This signal indicates a socket is ready for
  2188.         asynchronous I/O.  This signal will be sent only if
  2189.         the socket has been set to async by calling ioctl()
  2190.         with a command of FIOASYNC.
  2191.  
  2192.     SIGURG  This signal indicates the presence of urgent or
  2193.         out-of-band data on a TCP socket.
  2194.    INPUTS
  2195.     type        - SIGIO or SIGURG.
  2196.  
  2197.    RESULT
  2198.     signal        - signal bit (0..31) or -1 if 'type' was invalid.
  2199.  
  2200.    EXAMPLE
  2201.  
  2202.    NOTES
  2203.     The SIGIO signal will only be set for sockets on which FIOASYNC has
  2204.     been set (with s_ioctl or s_setsockopts.)
  2205.  
  2206.    BUGS
  2207.  
  2208.    SEE ALSO
  2209.     s_ioctl(), select(), selectwait()
  2210.  
  2211. socket.library/s_inherit                             socket.library/s_inherit
  2212.  
  2213.    NAME
  2214.     s_inherit -- inherit a socket
  2215.  
  2216.    SYNOPSIS
  2217.     s = s_inherit( sockptr );
  2218.     D0                D1
  2219.  
  2220.     int s_inherit( void * );
  2221.  
  2222.    FUNCTION
  2223.     This function along with s_release() provide a way to pass a
  2224.     socket from one process to another.  s_inherit() will attach
  2225.     a socket that has been released to your process. Use instead
  2226.     of socket() when another process hands you a socket.
  2227.  
  2228.    INPUTS
  2229.     sockptr        - really a pointer to an internal socket structure
  2230.  
  2231.    RESULT
  2232.     s        - socket descriptor (-1 on failure)
  2233.  
  2234.    EXAMPLE
  2235.     void main(void)
  2236.     {
  2237.         int errno, s;
  2238.         long opts[OPT_COUNT];
  2239.         struct RDargs *rdargs;
  2240.  
  2241.         memset((char *)opts, 0, sizeof(opts));
  2242.         rdargs = ReadArgs(TEMPLATE, opts, NULL);
  2243.  
  2244.         if ((SockBase = OpenLibrary( "inet:libs/socket.library", 1L ))==NULL) {
  2245.             goto exit1;
  2246.         }
  2247.         setup_sockets(5,&errno);
  2248.  
  2249.         / * now get our socket * / 
  2250.         s = s_inherit((void *)*(long *)opts[OPT_SOCKPTR]);
  2251.  
  2252.  
  2253.    NOTES
  2254.     Use with caution.  Calling s_inherit() with an invalid sockptr
  2255.     will cause serious problems.
  2256.     
  2257.    BUGS
  2258.     Not safe if an invalid pointer is passed.
  2259.  
  2260.    SEE ALSO
  2261.     s_release()
  2262.  
  2263. socket.library/s_ioctl                                 socket.library/s_ioctl
  2264.  
  2265.    NAME
  2266.        s_ioctl -- Control socket options.
  2267.  
  2268.    SYNOPSIS
  2269.        return = s_ioctl( s, cmd, data )
  2270.        D0              D0 D1   A0
  2271.  
  2272.        int s_ioctl ( int, int, char * );
  2273.  
  2274.    FUNCTION
  2275.     Manipulates device options for a socket.
  2276.  
  2277.    INPUTS
  2278.        s        - socket descriptor.
  2279.        cmd        - command.
  2280.        data        - data.
  2281.  
  2282.        The following commands are supported:
  2283.  
  2284.        command         description                     data points to
  2285.        -------         -----------                     --------------
  2286.        FIONBIO         set/clear nonblocking I/O       int
  2287.        FIOASYNC        set/clear async I/O             int
  2288.        FIONREAD        get number of bytes to read     int
  2289.        SIOCATMARK      at out-of-band mark?            int
  2290.        SIOCSPGRP       set process group               int
  2291.        SIOCGPGRP       get process group               int
  2292.        SIOCADDRT       add route                       struct rtentry
  2293.        SIOCDELRT       delete route                    struct rtentry
  2294.        SIOCGIFCONF     get ifnet list                  struct ifconf
  2295.        SIOCGIFFLAGS    get ifnet flags                 struct ifreq
  2296.        SIOCSIFFLAGS    set ifnet flags                 struct ifreq
  2297.        SIOCGIFMETRIC   get IF metric                   struct ifreq
  2298.        SIOCSIFMETRIC   set IF metric                   struct ifreq
  2299.        SIOCGARP        get ARP entry                   struct arpreq
  2300.        SIOCSARP        get ARP entry                   struct arpreq
  2301.        SIOCDARP        delete ARP entry                struct arpreq
  2302.  
  2303.        For more information, see a Unix reference manual.
  2304.  
  2305.    RESULT
  2306.        return        - 0 on success, else -1 (errno will be set to the
  2307.               specific error code).
  2308.  
  2309.    EXAMPLE
  2310.        int one = 1;
  2311.        ioctl ( s, FIOASYNC, (char *)&one);
  2312.  
  2313.    NOTES
  2314.        The standard Unix ioctl() function operates on both files and
  2315.        sockets.  Some compiler vendors may supply an ioctl() function.
  2316.        Because of this, and because this function works only with
  2317.        sockets, it has been renamed to s_ioctl().
  2318.  
  2319.    BUGS
  2320.  
  2321.    SEE ALSO
  2322.     setsockopts()
  2323.  
  2324. socket.library/s_release                             socket.library/s_release
  2325.  
  2326.    NAME
  2327.     s_release -- release a socket
  2328.  
  2329.    SYNOPSIS
  2330.     sockptr = s_release( s );
  2331.     D0                   D1
  2332.  
  2333.     void *s_release( int );
  2334.  
  2335.    FUNCTION
  2336.     This function along with s_inherit() provide a way to pass a
  2337.     socket from one process to another.  s_release(s) will 
  2338.     "detach" socket s from the current process.  Your process
  2339.     will no longer know about the socket.  You can not call
  2340.     s_close() on a socket you have released because it is no
  2341.     longer owned until it is s_inherit()ed. Once socket 's'
  2342.     is released, the socket descriptor 's' will be reused.
  2343.  
  2344.    INPUTS
  2345.     s        - socket descriptor
  2346.  
  2347.    RESULT
  2348.     sockptr        - really a pointer to an internal socket structure
  2349.                   NULL on failure    
  2350.  
  2351.    EXAMPLE
  2352.     sockptr = s_release(s);
  2353.     / * start a new program and pass socket on command line * /
  2354.     sprintf(cmdbuf, "run >nil: %s %ld", cmd_name,sockptr);
  2355.     Execute(cmdbuf, 0L, 0L);
  2356.  
  2357.    NOTES
  2358.     Use with caution.  Don't release a socket unless another
  2359.     process will s_inherit() it.
  2360.  
  2361.    BUGS
  2362.  
  2363.    SEE ALSO
  2364.     s_inherit()
  2365.  
  2366. socket.library/s_syslog                               socket.library/s_syslog
  2367.  
  2368.    NAME
  2369.     s_syslog - log system messages
  2370.  
  2371.    SYNOPSIS
  2372.     error = s_syslog( priority, message )
  2373.     D0              A0        D0
  2374.  
  2375.     int s_syslog( int, char * ) ;
  2376.  
  2377.    FUNCTION
  2378.     s_syslog() writes the 'message' argument to a console window and/or
  2379.     a specified file. The priority field is used to determine which,
  2380.     if any, of the above options is used. 
  2381.  
  2382.     The file "inet:s/inet.config" contains the optional fields:
  2383.  
  2384.       filepri        - msgs w/pri >= filepri are sent to file.
  2385.       windowpri      - msgs w/pri >= windowpri are sent to window.
  2386.       syslogfilename - the path/name of the file for filepri messages.
  2387.  
  2388.     Example:  (Note: this is the exact format to use in the 
  2389.                      'inet:s/inet.config' file.)
  2390.  
  2391.       filepri=5
  2392.       windowpri=3
  2393.       syslogfilename="t:foobar"
  2394.  
  2395.       These entries tell s_syslog how to deal with the messages it is 
  2396.       sent.  Note that the smaller the priority number, the greater 
  2397.       it's priority. Therefore, a message of priority 3 is of greater 
  2398.       importance than a message of priority 4. If you do not add these
  2399.       fields to you 'inet:s/inet.config' file, the default values will
  2400.       be used. The default values are:
  2401.  
  2402.         windowpri = 4
  2403.         filepri   = 3
  2404.         syslogfilename = "ram:syslog.dat"
  2405.  
  2406.       The above values mean:
  2407.  
  2408.         1. A message sent with a priority >= 4 (4,3,2,1,0) will
  2409.            be sent to BOTH the console window and the file
  2410.            'ram:syslog.dat'.
  2411.  
  2412.         2. A message sent with a priority >= 3 (3,2,1,0) will
  2413.            be sent to ONLY the console window.
  2414.  
  2415.         3. A message sent with a priority < 4 (5,6,7,8) will
  2416.            be ignored.
  2417.  
  2418.    INPUTS
  2419.     pri       - an integer value between 0-7
  2420.     message   - a string to be written to the console window and/or
  2421.                 the syslog file.
  2422.  
  2423.    RESULT
  2424.     error     - 0 (zero) is returned if everything went well. 
  2425.                 -1 is returned if anything went wrong.
  2426.  
  2427.       If an error has occurred, you need to examine your errno value
  2428.       to determine just what went wrong. It is possible, for example,
  2429.       to have a write to the console window succeed while a write of
  2430.       the same message to the file failed.  The various error values
  2431.       that occur during the syslog operation are OR'd together and
  2432.       returned in 'errno'. See the file "sys/syslog.h" for the values.
  2433.  
  2434.       Example:
  2435.  
  2436.       #include<sys/syslog.h>
  2437.          ...
  2438.        extern int errno ;
  2439.        int error ;
  2440.  
  2441.        error = s_syslog( 5, "This is a test\n") ;
  2442.        if( error == -1 )
  2443.        {
  2444.           if( errno & SYSLOGF_WINDOWOPEN )
  2445.           {
  2446.              printf("Could not open syslog window\n") ;
  2447.           }
  2448.           if( errno & SYSLOGF_FILEWRITE )
  2449.           {
  2450.              printf("Could not write to syslog file\n") ;
  2451.           }
  2452.        }
  2453.  
  2454.    NOTES
  2455.     1. s_syslog() will clear the global errno value with each call.
  2456.  
  2457.     2. Unlike the Unix syslog() function, the Amiga version does not
  2458.        handle printf-style arguments. This will need to be handled in
  2459.        the application.
  2460.  
  2461.     3. The maximum length of a syslogfilename line in inet.config is
  2462.        127 characters. This includes the 'syslogfilename=' portion
  2463.        of the line. 
  2464.  
  2465.        maxlen(path/filename) = 127 - len( "syslogfilename=" )
  2466.  
  2467.    BUGS
  2468.     none known
  2469.  
  2470.    SEE ALSO
  2471.     inet.config (in the AS225 manual)
  2472.  
  2473. socket.library/select                                   socket.library/select
  2474.  
  2475.    NAME
  2476.     select -- Examines specified sockets' read, write or exception status.
  2477.  
  2478.    SYNOPSIS
  2479.     num = select( numfds, readfds, writefds, exceptfds, timeout )
  2480.     D0            D0      A0       A1        A2         D1
  2481.  
  2482.     int select( int, fd_set *, fd_set *, fd_set *, struct timeval *);
  2483.  
  2484.    FUNCTION
  2485.     select() examines the socket masks specified 'readfds,' 'writefds,'
  2486.     and 'execptfds' (see FD_SET) to see if they are ready for reading,
  2487.     for writing, or have an exceptional condition pending.
  2488.  
  2489.     When select() returns, the masks will have been modified so that
  2490.     only the "bits" for those sockets on which an event has occured are
  2491.     set.  The total number of ready sockets is returned in 'num.'
  2492.  
  2493.     If 'timeout' is a non-NULL pointer, it specifies a maximum
  2494.     interval to wait for the selection to complete. If timeout is
  2495.     a NULL pointer, the select blocks indefinitely. To affect a
  2496.     poll, the timeout argument should be nonzero, pointing to a
  2497.     zero valued timeval structure.  As you know, busy-loop polling
  2498.     is a no-no on the Amiga.
  2499.  
  2500.     Any of readfds, writefds, and execptfds may be given as NULL if
  2501.     any of those categories are not of interest.
  2502.  
  2503.     select() should not be used with a single socket (use s_getsignal()
  2504.     and Wait() instead).
  2505.  
  2506.    INPUTS
  2507.     numfds    - Maximum number of bits in the masks that
  2508.                 represent valid file descriptors.
  2509.     readfds   - 32 bit mask representing read file descriptors
  2510.     writefds  - 32 bit mask representing write file descriptors
  2511.     exceptfds - 32 bit mask representing except file descriptors
  2512.     timeout   - Pointer to a timeval structure which holds the
  2513.                 maximum amount of time to wait for the selection
  2514.                 to complete.
  2515.  
  2516.    RESULT
  2517.     num       - The number of ready sockets, zero if a timeout occurred,
  2518.                 -1 on error.
  2519.     readfds   - A mask of the ready socket descriptors
  2520.     writefds  -      "      "     "     "      "
  2521.     exceptfds -      "      "     "     "      "
  2522.  
  2523.    NOTES
  2524.     If a process is blocked on a select() waiting for input from a
  2525.     socket and the sending process closes the socket, the select
  2526.     notes this as an exception rather than as data.  Hence, if
  2527.     the select is not currently looking for exceptions, it will
  2528.     wait forever.
  2529.  
  2530.     The descriptor masks are always modified on return, even if
  2531.     the call returns as the result of the timeout.
  2532.  
  2533.     The current version of this function calls selectwait()
  2534.     with a control-C option in the umask field.
  2535.  
  2536.     A common error is to use the socket number in which you are
  2537.     interested as the first argument. Use socket+1.
  2538.  
  2539.    BUGS
  2540.  
  2541.    SEE ALSO
  2542.     FD_SET(), selectwait(), s_getsignal()
  2543.  
  2544. socket.library/selectwait                           socket.library/selectwait
  2545.  
  2546.    NAME
  2547.     selectwait -- select() with optional, task specific Wait() mask.
  2548.  
  2549.    SYNOPSIS
  2550.     num = selectwait( numfds, rfds, wfds, exfds, time, umask )
  2551.     D0                D0      A0    A1    A2     D1    D2
  2552.  
  2553.     int selectwait (int, int *, int *, int *, struct timeval *, long *);
  2554.  
  2555.    FUNCTION
  2556.     selectwait() is the same as select() except that it processes
  2557.     one additional argument, 'umask'
  2558.  
  2559.     The umask argument should contain either a NULL or a mask
  2560.     of the desired task-specific signal bits that will be tested
  2561.     along with the socket descriptors.  selectwait() does a standard
  2562.     Exec Wait() call and adds the supplied mask value to Wait()
  2563.     argument.
  2564.  
  2565.    INPUTS
  2566.     numfds    - The maximum number of bits in the masks that
  2567.                 represent valid file descriptors.
  2568.     readfds   - 32 bit mask representing read file descriptors
  2569.     writefds  - 32 bit mask representing write file descriptors
  2570.     exceptfds - 32 bit mask representing except file descriptors
  2571.     timeout   - A pointer to a timeval structure which holds the
  2572.                 maximum amount of time to wait for the selection
  2573.                 to complete.
  2574.     umask     - A mask of the task's signal bits that will be
  2575.                 used (in addition to the standard select() call
  2576.                 return options) to have the call return. This can
  2577.                 be SIGBREAKF signals, Intuition userport signals,
  2578.                 console port signals, etc. Any mask that you would
  2579.                 pass to the the Exec Wait() call is ok here.
  2580.  
  2581.    RESULT
  2582.     num       - The number of ready file descriptors if
  2583.                 successful.  Zero (0) if a timeout occurred.
  2584.                 (-1) upon error.
  2585.     readfds   - A mask of the ready file descriptors
  2586.     writefds  -      "      "     "     "      "
  2587.     exceptfds -      "      "     "     "      "
  2588.     umask     - A mask of the bits in the originally passed 'umask'
  2589.                 variable that have actually occured.
  2590.  
  2591.    EXAMPLE
  2592.     long umask = SIGBREAKF_CTRL_D | 1L << myport->mp_SigBit ;
  2593.  
  2594.     numfds = selectwait(n, r, w, e, time, &umask) ;
  2595.     if( event & SIGBREAKF_CTRL_D ) {
  2596.         printf("user hit CTRL-D\n") ;
  2597.     }
  2598.     if( event & 1L << myport->mp_SigBit ) {
  2599.         printf( "myport got a message\n" ) ;
  2600.     }
  2601.    NOTES
  2602.     A common error is to use the socket number in which you are
  2603.     interested as the first argument. Use socket+1.
  2604.  
  2605.    BUGS
  2606.  
  2607.    SEE ALSO
  2608.     FD_SET(), select(), s_getsignal()
  2609.  
  2610. socket.library/send                                       socket.library/send
  2611.  
  2612.    NAME
  2613.     send, sendto, sendmsg -- Send data from a socket.
  2614.  
  2615.    SYNOPSIS
  2616.     #include <sys/types.h>
  2617.     #include <sys/socket.h>
  2618.  
  2619.     cc = send( s, buf, len, flags )
  2620.     D0         D0 A0   D1   A1
  2621.  
  2622.     cc = sendto ( s, buf, len, flags, to, to_len )
  2623.     D0            D0 A0   D1   D2     A1  D3
  2624.  
  2625.     cc = sendmsg( s, msg, flags )
  2626.     D0            D0 A0   D1
  2627.  
  2628.     int send (int, char *, int, int );
  2629.     int sendto (int, char *, int, int, struct sockaddr *, int );
  2630.     int sendmsg (int, struct msghdr *, int );
  2631.  
  2632.    FUNCTION
  2633.     send(), sendto(), and sendmsg() transmit data from a socket.
  2634.     send() must be used with a connect()ed socket.  sendto() can
  2635.     only be used with non-connect()ed DGRAM-type sockets.  sendmsg()
  2636.     is an advanced function.
  2637.  
  2638.    INPUTS
  2639.     s           - socket descriptor.
  2640.     buf         - pointer to message buffer.
  2641.     len         - length of message to transmit.
  2642.     flags       - 0 or MSG_OOB to send out-of-band data.
  2643.     to          - pointer to a sockaddr containing the destination.
  2644.     to_len      - sizeof(struct sockaddr).
  2645.     msg         - pointer to a struct msghdr, defined in
  2646.               "sys/socket.h."
  2647.  
  2648.    RESULT
  2649.     cc        - the number of bytes sent. This does not imply that
  2650.               the bytes were recieved.  -1 is returned on a local
  2651.               error (errno will be set to the specific error
  2652.               code).  Possible errors are:
  2653.  
  2654.         EBADF        an invalid descriptor was used
  2655.         ENOTSOCK    's' is not a socket
  2656.         EMSGSIZE    the socket requires that the message be
  2657.                 sent atomically and the size of the message
  2658.                 prevents that.
  2659.         EWOULDBLOCK    requested operation would block
  2660.  
  2661.    EXAMPLE
  2662.  
  2663.    NOTES
  2664.  
  2665.    BUGS
  2666.  
  2667.    SEE ALSO
  2668.     recv(), socket()
  2669.  
  2670. socket.library/sethostent                           socket.library/sethostent
  2671.  
  2672.    NAME
  2673.     sethostent -- Rewind the hosts file ("inet:s/hosts").
  2674.  
  2675.    SYNOPSIS
  2676.     sethostent( flag )
  2677.  
  2678.     void sethostent( int );
  2679.                      D1
  2680.  
  2681.    FUNCTION
  2682.     This function is rarely useful.
  2683.  
  2684.     Opens the host file if necessary.  Rewinds the host file if it
  2685.     is open.
  2686.  
  2687.    INPUTS
  2688.     flag        - If 'flag' is 1, calls to gethostbyname() and
  2689.               gethostbyaddr() will not close the file between
  2690.               calls.  You must close the file with an
  2691.               endhostent().  Once set, 'flag' cannot be reset
  2692.               except by calling endhostent().
  2693.  
  2694.    RESULT
  2695.     None.
  2696.  
  2697.    EXAMPLE
  2698.  
  2699.    NOTES
  2700.  
  2701.    BUGS
  2702.  
  2703.    SEE ALSO
  2704.     gethostent(), gethostbyname(), gethostbyaddr(), endhostent()
  2705.  
  2706. socket.library/setnetent                             socket.library/setnetent
  2707.  
  2708.    NAME
  2709.     setnetent -- Open or rewind the networks file.
  2710.  
  2711.    SYNOPSIS
  2712.     setnetent( flag )
  2713.                   D1
  2714.  
  2715.     void setnetent( int );
  2716.  
  2717.    FUNCTION
  2718.     Rewinds the network file if it is open.
  2719.     Opens the network file if it was not open.
  2720.  
  2721.    INPUTS
  2722.     flag        - if 'flag' is 1, calls to getnetbyname() and
  2723.               getnetbyaddr() will not close the file between
  2724.               calls.  You must close the file with an endnetent().
  2725.               Once set, 'flag' cannot be reset except by calling
  2726.               endnetent().
  2727.  
  2728.    RESULT
  2729.     None.
  2730.  
  2731.    EXAMPLE
  2732.  
  2733.    NOTES
  2734.  
  2735.    BUGS
  2736.  
  2737.    SEE ALSO
  2738.     getnetent(), getnetbyname(), getnetbyaddr(), endnetent()
  2739.  
  2740. socket.library/setprotoent                         socket.library/setprotoent
  2741.  
  2742.    NAME
  2743.     setprotoent -- Open or rewind the protocols file.
  2744.  
  2745.    SYNOPSIS
  2746.     setprotoent( flag )
  2747.  
  2748.     void setprotoent( int );
  2749.                       D1
  2750.  
  2751.    FUNCTION
  2752.     This function is rarely useful.
  2753.  
  2754.     Opens the protocols file if necessary.
  2755.     Rewinds the protocols file if it is open.
  2756.  
  2757.    INPUTS
  2758.     flag        - if 'flag' is 1, calls to getprotobyname() and
  2759.               getprotobynumber() will not close the file
  2760.               between calls.  You must close the file with an
  2761.               endprotoent().  Once set, 'flag' cannot be reset
  2762.               except by calling endprotoent().
  2763.    RESULT
  2764.     None.
  2765.  
  2766.    EXAMPLE
  2767.  
  2768.    NOTES
  2769.  
  2770.    BUGS
  2771.  
  2772.    SEE ALSO
  2773.     getprotoent(), endprotoent(), getprotobyname(), getprotobynumber()
  2774.  
  2775. socket.library/setpwent                               socket.library/setpwent
  2776.  
  2777.    NAME
  2778.     setpwent - Opens or rewinds the password file.
  2779.  
  2780.    SYNOPSIS
  2781.     setpwent( flag )
  2782.               D1
  2783.  
  2784.     void setpwent( int );
  2785.  
  2786.    FUNCTION
  2787.     If the file is already open the file is rewound. Otherwise the
  2788.     file is opened.
  2789.  
  2790.    INPUTS
  2791.     flag        - if 'flag' is 1, calls to getpwuid() and getpwnam()
  2792.               will not close the file between calls.  You must
  2793.               close the file with an endpwent().  Once set,
  2794.               'flag' cannot be reset except by calling endpwent().
  2795.  
  2796.    RESULT
  2797.     None.
  2798.  
  2799.    SEE ALSO
  2800.     endpwent(), getpwent()
  2801.  
  2802. socket.library/setservent                           socket.library/setservent
  2803.  
  2804.    NAME
  2805.     setservent -- Open or rewind the services file.
  2806.  
  2807.    SYNOPSIS
  2808.     setservent( flag )
  2809.                 D1
  2810.  
  2811.     void setservent( int );
  2812.  
  2813.    FUNCTION
  2814.     This function is rarely useful.
  2815.  
  2816.     Opens the services file if necessary.
  2817.     Rewinds the services file if it is open.
  2818.  
  2819.    INPUTS
  2820.     flag        - if 'flag' is 1, calls to getservbyport() and
  2821.               getservbyname() will not close the file between
  2822.               calls.  You must close the file with an
  2823.               endservent().  Once set, 'flag' cannot be reset
  2824.               except by calling endservent().
  2825.  
  2826.    EXAMPLE
  2827.  
  2828.    NOTES
  2829.  
  2830.    BUGS
  2831.  
  2832.    SEE ALSO
  2833.     getservent(), endservent()
  2834.  
  2835. socket.library/setsockopt                           socket.library/setsockopt
  2836.  
  2837.    NAME
  2838.     setsockopt -- Set socket options.
  2839.  
  2840.    SYNOPSIS
  2841.     return = setsockopt( s, level, optname, optval, optlen )
  2842.     D0                   D0 D1     D2       A0      D3
  2843.  
  2844.     int setsockopt( int, int, int, char *, int );
  2845.  
  2846.    FUNCTION
  2847.     Sets the option specified by 'optname' for socket 's.'
  2848.     This is an advanced function.  See the "sys/socket.h" header and
  2849.     your favorite TCP/IP reference for more information on options.
  2850.  
  2851.    INPUTS
  2852.     s        - socket descriptor.
  2853.     level        - protocol level.  Valid levels are:
  2854.                IPPROTO_IP    IP options
  2855.                IPPROTO_TCP    TCP options
  2856.                SOL_SOCKET    socket options
  2857.     optname        - option name.
  2858.     optval        - pointer to the buffer with the new value.
  2859.     optlen        - size of 'optval' (in bytes).
  2860.  
  2861.    RESULT
  2862.     return        - 0 if successful else -1 (errno will contain the
  2863.               specific error).
  2864.  
  2865.    EXAMPLE
  2866.         int on = 1;
  2867.         setsockopt( s, SOL_SOCKET, SO_DEBUG, &on, (int)sizeof(on));
  2868.  
  2869.    NOTES
  2870.  
  2871.    BUGS
  2872.  
  2873.    SEE ALSO
  2874.     getsockopt()
  2875.  
  2876. socket.library/setup_sockets                     socket.library/setup_sockets
  2877.  
  2878.    NAME
  2879.     setup_sockets -- Initialize global data for sockets.
  2880.  
  2881.    SYNOPSIS
  2882.     retval = setup_sockets( max_sockets, errnop );
  2883.     D0                      D1           A0
  2884.  
  2885.     ULONG setup_sockets( UWORD, int * );
  2886.  
  2887.    FUNCTION
  2888.     This function initializes global variables, sets the library errno
  2889.     to point to the application's errno, and allocates signals.
  2890.     This should always be called immediately after an OpenLibrary().
  2891.     The only reason this initialization is not done automatically
  2892.     is because a pointer to errno must be passed in.
  2893.  
  2894.     'max_sockets' must be less than FD_SETSIZE.
  2895.  
  2896.    INPUTS
  2897.     max_sockets    - maximum number of sockets that can be open at once.
  2898.               (4 bytes are allocated for each socket.)
  2899.     errno        - pointer to the global int 'errno.'
  2900.  
  2901.    RESULT
  2902.     retval        - TRUE on success, FALSE on failure.  If 'max_sockets'
  2903.               is greater than FD_SETSIZE, setup_sockets() will
  2904.               fail.  FD_SETSIZE is currently 128 (see
  2905.               <sys/types.h>)
  2906.  
  2907.    NOTES
  2908.     If you are using a language other than C, you must pass in a pointer
  2909.     to a variable that will hold the error numbers.
  2910.  
  2911.     In SAS C, errno is a global in lc.lib.  If you don't link with lc.lib
  2912.     you will have to declare errno locally.
  2913.  
  2914.    BUGS
  2915.  
  2916.    SEE ALSO
  2917.     cleanup_sockets()
  2918.  
  2919. socket.library/shutdown                               socket.library/shutdown
  2920.  
  2921.    NAME
  2922.     shutdown -- Shut down part of a full-duplex connection.
  2923.  
  2924.    SYNOPSIS
  2925.     return = shutdown( s, how )
  2926.     D0                 D0 D1
  2927.  
  2928.     int shutdown(int, int);
  2929.  
  2930.    FUNCTION
  2931.     Sockets are normally terminated by using just s_close().  However,
  2932.     s_close() will attempt to deliver any data that is still pending.
  2933.     Further, shutdown() provides more control over how a connection is
  2934.     terminated.  You should eventually use s_close() on all sockets you
  2935.     own, regardless of what shutdown() is done on those sockets.
  2936.  
  2937.    INPUTS
  2938.     s        - socket descriptor.
  2939.     how        - 'how' can be one of the following:
  2940.               0    disallow further receives
  2941.               1    disallow further sends
  2942.               2    disallow further sends and receives
  2943.  
  2944.    RESULT
  2945.     return        - 0 if successful else -1 (errno will contain the
  2946.               specific error).
  2947.  
  2948.    EXAMPLE
  2949.  
  2950.    NOTES
  2951.  
  2952.    BUGS
  2953.  
  2954.    SEE ALSO
  2955.        s_close()
  2956.  
  2957. socket.library/socket                                   socket.library/socket
  2958.  
  2959.    NAME
  2960.     socket -- Create an endpoint for communication.
  2961.  
  2962.    SYNOPSIS
  2963.     s = socket( family, type, protocol )
  2964.     D0          D0      D1    D2
  2965.  
  2966.     int socket( int, int, int );
  2967.  
  2968.    FUNCTION
  2969.     socket() returns a socket descriptor for a socket with .
  2970.  
  2971.    INPUTS
  2972.     family   - This specifies an address format with which
  2973.                addresses specified in later operations using
  2974.                socket should be interpreted.
  2975.     type     - Specifies the semantice of communication.
  2976.     protocol - Specifies a particular protocol to be used with the
  2977.                socket.
  2978.  
  2979.    RESULT
  2980.     s        - Returns a (-1) upon failure  ; a socket descriptor
  2981.                upon success.
  2982.  
  2983.    NOTES
  2984.     Unlike the linkable socket library, this function assumes that
  2985.     you have already made a succesful call to 'setup_sockets()'.
  2986.  
  2987.    SEE ALSO
  2988.  
  2989. socket.library/strerror                               socket.library/strerror
  2990.  
  2991.    NAME
  2992.     strerror - Returns a pointer to an error message.
  2993.  
  2994.    SYNOPSIS
  2995.     #include <string.h>
  2996.  
  2997.     error = strerror( error_number )
  2998.     D0                D1
  2999.  
  3000.     char *strerror( int );
  3001.  
  3002.    FUNCTION
  3003.     The strerror() function maps the error number to a language-
  3004.     dependent Unix error message.
  3005.  
  3006.    INPUTS
  3007.     error_number     - usually the value of errno.
  3008.  
  3009.    RESULT
  3010.     error        - pointer to the error message.
  3011.  
  3012.    NOTES
  3013.     This function should eventually be localized.
  3014.  
  3015.    SEE ALSO
  3016.     <errno.h>,  perror()
  3017.  
  3018. socket.library/umask                                     socket.library/umask
  3019.  
  3020.    NAME
  3021.     umask  -- get and set user file creation mask
  3022.  
  3023.    SYNOPSIS
  3024.     #include <sys/types.h>
  3025.  
  3026.     umask = umask( cmask )
  3027.     D0             D0
  3028.  
  3029.     mode_t umask ( mode_t );
  3030.  
  3031.    FUNCTION
  3032.     The umask() function sets the file creation mask to 'cmask'
  3033.     and returns the old value of the mask.
  3034.  
  3035.    RESULT
  3036.     -1 will be returned and an error message will be displayed
  3037.     if there is a problem reading the current configuration.
  3038.  
  3039.    EXAMPLE
  3040.  
  3041.    NOTES
  3042.     Amiga filesystems, of course, will not use this file creation
  3043.     mask.  We use it for NFS, and provide it in case you can think
  3044.     of something to use it for.
  3045.  
  3046.     The new mask value is not saved to the configuration file. It
  3047.     will be reset when the machine is rebooted.
  3048.  
  3049.     Currently, the configuration information is stored in memory
  3050.     in a configuration structure.  If this structure cannot be
  3051.     found, it will be initialized by reading in inet:s/inet.config.
  3052.     This may change in the future.
  3053.  
  3054.  
  3055.    BUGS
  3056.  
  3057.    SEE ALSO
  3058.     getumask()
  3059.  
  3060.